This script is inside a tool, in the StarterPack. It works fine the first time it runs, but when I reset, It gives the following error:
00:54:25.724 - LoadAnimation requires the Humanoid object (Player1.Humanoid) to be a descendant of the game object
I am using Filtering enabled/Non-experimental mode, so I suspect the issue is from it, since this only happens in the client/in game but not in the Studio
--//This script handles the animation and functionality --//Variables\\-- local Tool = script.Parent.Parent local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local Mouse = Player:GetMouse() local Humanoid = Character:WaitForChild("Humanoid") local AnimFolder = Tool:WaitForChild("Animations") local Storage = game.ReplicatedStorage local EventsFolder = Storage:WaitForChild("Events") local FunctionsFolder = Storage:WaitForChild("Functions") --//Remote Events\\-- --//Animations\\-- local HoldAnimation = AnimFolder:WaitForChild("Hold") local SwingAnimation = AnimFolder:WaitForChild("Swing") --//Animation Tracks\\-- repeat wait() until Character.Humanoid print(tostring(Humanoid), typeof(Humanoid)) --For debugging local HoldTrack = Humanoid:LoadAnimation(HoldAnimation) --Error occurs here local SwingTrack = Humanoid:LoadAnimation(SwingAnimation) --And here --//Events\\-- Tool.Equipped:connect(function() HoldTrack:Play() Tool.Activated:connect(function() SwingTrack:Play() end) end) Tool.Unequipped:connect(function() HoldTrack:Stop() SwingTrack:Stop() end)
Roblox Forums didn't help one bit, so I expect people here would be more helpful Thanks in advance :)
The CharacterAdded event fires before the character has been added to the workspace. Add the following line before you run LoadAnimation.
repeat wait() until Character.Parent