#why is this happening?

5 messages · Page 1 of 1 (latest)

sacred lily
#

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

-- Set your animation ID here
local animationId = "rbxassetid://103404072113300"
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local animationTrack

-- Function to play the animation
local function playAnimation()
if not animationTrack then
animationTrack = humanoid:LoadAnimation(animation)
end
if not animationTrack.IsPlaying then
animationTrack:Play()
end
end

-- Function to stop the animation
local function stopAnimation()
if animationTrack and animationTrack.IsPlaying then
animationTrack:Stop()
end
end

-- Connect to the Running event
humanoid.Running:Connect(function(speed)
if speed > 0 and humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
playAnimation()
else
stopAnimation()
end
end)

-- Connect to the Jumping event
humanoid.Jumping:Connect(function(isJumping)
if isJumping then
stopAnimation()
end
end)

-- Additional check for when the character lands
humanoid.StateChanged:Connect(function(_, newState)
if newState == Enum.HumanoidStateType.Freefall then
stopAnimation()
elseif newState == Enum.HumanoidStateType.GettingUp then
stopAnimation()
end
end)

#

try this

#

i labeled some of the functions and stuff so you can see whats diffrent

#

let me know if it wokrs

#

*works