I am having trouble on why it says Character is a nil value, this is the error: 19:19:21.294 - Players.Microsoft_Net.Backpack.Tool.LocalScript:3: attempt to index local 'Character' (a nil value)
Here is the code :
local Tool = script.Parent local Player = game.Players.LocalPlayer local Humanoid = Player.Character:FindFirstChild("Humanoid") local Animation = Humanoid:LoadAnimation(Tool.Animation) Tool.Equipped:Connect(function() Animation:Play() end)
Help?
You can't assume the character is loaded by the time you reference it in your script; in fact, it will virtually never be loaded in time if you try to reference it at the beginning of a local script. You have to wait for it:
local Tool = script.Parent local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local Animation = Humanoid:LoadAnimation(Tool.Animation) Tool.Equipped:Connect(function() Animation:Play() end)