I have a LocalScript inside a tool that is supposed to make it auto-equip. However, the same error (attempt to index a nil value
) keeps appearing no matter how I change the script.
Script:
while true do wait(.5) game.Workspace:FindFirstChild(game.Players.LocalPlayer).Humanoid:EquipTool(script.Parent) end
The script will immediately find the LocalPlayer, which is successful, but not the Humanoid, which is not a property of LocalPlayer. Access the Character from the LocalPlayer first before the Humanoid. Also, to make it work, your code must wait until the local player's character loaded. This is the correct way:
localplr = game.Players.LocalPlayer char = localplr.CharacterAdded:wait() -- Use the event CharacterAdded, then add ":wait()" while true do wait(.5) if char:FindFirstChild('Humanoid') then -- your code end end
You're welcome.