01 | local tool = script.Parent |
02 | local player = game.Players.LocalPlayer |
03 | local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait() |
04 | local animation |
05 | local anim = script.Parent:WaitForChild( "Animation" ):Clone() |
06 | tool.Equipped:Connect( function () |
07 | animation = character:WaitForChild( "Humanoid" ):LoadAnimation(anime) |
08 | character = character or tool.Parent or player.Character or player.CharacterAdded:Wait() |
09 |
10 | if not animation then |
11 | animation = character.Humanoid:LoadAnimation(animation) |
12 | end |
13 | end ) |
14 | script.Parent.Unequipped:Connect( function () |
15 | animation:Stop() |
16 | end ) |
I made a team change script that resets the character, then the animation of the tool is completely broken? how do I fix it?
When I reset this error shows up.
animation =character:WaitForChild("Humanoid"):LoadAnimation(anime)
typo :)
edit:
01 | local tool = script.Parent |
02 | local player = game.Players.LocalPlayer |
03 | local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait() |
04 | local anim = script.Parent:WaitForChild( "Animation" ) --No need to clone it |
05 | tool.Equipped:Connect( function () |
06 | animation = character:WaitForChild( "Humanoid" ):LoadAnimation(anim) |
07 | if not animation then |
08 | animation = character.Humanoid:LoadAnimation(animation) |
09 | end |
10 | animation:Play() |
11 | end ) |
12 | script.Parent.Unequipped:Connect( function () |
13 | animation:Stop() |
14 | end ) |
01 | local animation |
02 | script.Parent.Equipped:Connect( function () |
03 | animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) |
04 | animation:Play() |
05 | end ) |
06 |
07 | script.Parent.Unequipped:Connect( function () |
08 | animation:Stop() |
09 | end ) |
10 | --Script that does work |
I have fixed that. I found another script of animation that I have made a while ago that does work, I don't know what the error is but at least it works now.
I had this problem too...
Check if there is any other instance in your game that has your name