Loading...
Loading...
Characters and animation - Humanoid properties/states, spawning (LoadCharacterAsync), health and damage, HumanoidDescription appearance, Animator/AnimationTrack playback, priorities and markers, default animation replacement, Tools, TweenService, IKControl, Character Controller Library (beta). Use when changing movement, abilities, damage, respawn, avatars, animations, tweens, or tools/weapons.
npx skill4agent add el4cteo/roblox-skills roblox-characters-animationModelHumanoidHumanoidRootPartcharacter:PivotTo(cframe)AnimateStarterPlayerCharacterWalkSpeedCharacterJumpHeightCharacterUseJumpPowerCharacterJumpPowerModelStarterCharacterStarterPlayerPlayers.CharacterAutoLoads = falseplayer:LoadCharacterAsync()LoadCharacterCharacterAddedWalkSpeedJumpHeightroblox-securityroblox-physics--!strict
local Players = game:GetService("Players")
local function damage(target: Model, amount: number, source: Player?)
local humanoid = target:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then
return
end
humanoid:SetAttribute("LastDamagedBy", if source then source.UserId else 0)
humanoid:TakeDamage(amount) -- respects ForceField; use Health -= amount to bypass
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid") :: Humanoid
humanoid.MaxHealth = 150
humanoid.Health = 150
humanoid.Died:Once(function()
local killerId = humanoid:GetAttribute("LastDamagedBy")
print(`{player.Name} died (killer {killerId})`)
end)
end)
end)
return damageHealthStarterCharacterScriptsHumanoid.BreakJointsOnDeath = falsehumanoid:ChangeState(Enum.HumanoidStateType.Jumping)SetStateEnabled(state, false)StateChangedMoveDirectionFloorMaterialRootPartSeatParthumanoid:MoveTo(position)roblox-npc-ai--!strict
local Players = game:GetService("Players")
local function applyUniform(player: Player)
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if not humanoid then
return
end
local ok, description = pcall(function()
return Players:GetHumanoidDescriptionFromUserIdAsync(player.UserId)
end)
if not ok then
return
end
description.Shirt = 123456 -- asset ids
description.Pants = 654321
description.HeightScale = 1.05
pcall(function()
humanoid:ApplyDescriptionAsync(description) -- server-side; replicates
end)
end
return applyUniformPlayer:LoadCharacterWithHumanoidDescriptionAsync(description)ApplyDescriptionGetHumanoidDescriptionFromUserId--!strict
local function playAttack(character: Model, animation: Animation): AnimationTrack?
local humanoid = character:FindFirstChildOfClass("Humanoid")
local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")
if not animator then
return nil
end
local track = animator:LoadAnimation(animation) -- Humanoid:LoadAnimation is deprecated
track.Priority = Enum.AnimationPriority.Action
track.Looped = false
track:GetMarkerReachedSignal("Hit"):Connect(function(param)
print("hit frame reached", param) -- apply damage window, play sound, etc.
end)
track:Play(0.1) -- fade time
return track
end
return playAttackAnimationLoadAnimationCore < Idle < Movement < Action < Action2 < Action3 < Action4AdjustWeightAdjustSpeedStop(fadeTime)track.Stoppedtrack.EndedGetMarkerReachedSignalKeyframeReachedAnimateStringValueAnimationanimate.run.RunAnim.AnimationIdCharacterAddedAnimateStarterCharacterScriptsIKControl--!strict
local TweenService = game:GetService("TweenService")
local door = Instance.new("Part")
door.Anchored = true
door.Parent = workspace
local info = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local open = TweenService:Create(door, info, { CFrame = door.CFrame * CFrame.new(0, 8, 0) })
open.Completed:Once(function(state)
print("door tween finished:", state)
end)
open:Play()CFrameValuemodel:PivotTo(value)ChangedTweenService:GetValue(alpha, style, direction)SmoothDampToolStarterPackBackpackHandleRequiresHandle = falseEquippedUnequippedActivatedActivatedrequire("@rbx/AvatarAbilities")StartsWhenRunsWhileAllAnyNotBlocksStopsSuspendsroblox-npc-airoblox-physicsroblox-inputroblox-securityroblox-game-systems