Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool animation breaks after the player dies?

Asked by 3 years ago

So I am trying to figure out how to put animations in tools and it makes absolutely no sense. I've been able to have the animation work and everything but when the player dies and respawns it gives an error saying the animation isn't found in the script, and when I go into the tool after the error is shown the animation is clearly there. Here is the code in a local script in the tool:


local SWING_TIME = 2 local Players = game:GetService("Players") local canSwing = true local tool = script.Parent local player = Players.LocalPlayer local character = player.Character if not character then character = player.CharacterAdded:Wait() end local humanoid = character:WaitForChild("Humanoid") local r6swing = script:WaitForChild("R6AnimationSwing") local r15swing = script:WaitForChild("R15AnimationSwing") while not character:IsDescendantOf(game.Workspace) do wait() end local rigType = humanoid.RigType local swing = nil if rigType == Enum.HumanoidRigType.R15 then swing = humanoid:LoadAnimation(r15swing) elseif rigType == Enum.HumanoidRigType.R6 then swing = humanoid:LoadAnimation(r6swing) end while swing.Length == 0 do wait() end local swingSpeed = swing.Length / SWING_TIME local function swingTool() if canSwing == true then -- Keep user from clicking until animation finishes canSwing = false swing:Play() swing:AdjustSpeed(swingSpeed) wait(SWING_TIME) canSwing = true end end tool.Activated:Connect(swingTool)
0
Do you have a model so I can try it out in studio? User#30567 0 — 3y

1 answer

Log in to vote
0
Answered by
iivSnooxy 248 Moderation Voter
3 years ago

Did you watch the video I gave you? https://www.youtube.com/watch?v=sC84mj1-h9Y It’ll help I promise!

0
I followed the video and it still doesn't work. All the videos and articles I have seen have not worked GooseStranger 27 — 3y
0
I’m so sorry :( iivSnooxy 248 — 3y
Ad

Answer this question