Hello, I have been looking for ages, I have found multiple other topics on this, and tried all of them, but none of them have been helpful, as the animation still only plays once.
Here is a video:
And here is my code:
game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
char:SetAttribute("KatanaEquipped", false)
local idle = humanoid:LoadAnimation(script.Idle)
local running = humanoid:LoadAnimation(script.Running)
local playingrun = false
local playingidle = false
local activated = false
while wait() do
local magnitude = humanoid.MoveDirection.Magnitude
local speed = humanoid.WalkSpeed
local equipped = char:GetAttribute("KatanaEquipped")
if activated == true then
if equipped == false then
idle:Stop()
running:Stop()
activated = false
end
end
local function main()
if equipped == true then
activated = true
if magnitude <= 1 and magnitude > 0 then
if speed > 16 then
print("Sprinting")
else
if playingrun == false then
playingrun = true
playingidle = false
idle:Stop()
running:Play()
end
end
end
if magnitude == 0 then
if playingidle == false then
playingidle = true
playingrun = false
idle:Play()
running:Stop()
end
end
end
end
main()
end
end)
How do I fix this annoying issue? Thanks for any help in advance.
sorry,
when i unsheathe the katana, the animation plays and the player holds it to the right a little bit. when i sheathe and unsheathe it again, the player holds it forward. it also does it with walking.
and also the animation starts again when i move and go idle again.
thank you,
I really don’t know what is going on then, it just stops working the second time, I dont think there is any error in the code to unload the animation, I wouldnt really know