I have this script that is not working for some reason. when i play it says Attempt to index field localplayer (a nil value) line 8 It looks right to me. is there anything wrong with it?
local enabled = true
script.Parent.Touched:connect(function(hit)
if enabled == true then
enabled =false
local name = hit.Parent.Name
local hunger = game.Workspace.hungervalues:FindFirstChild(name)
local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=633050771"
local playAnim = humanoid:LoadAnimation(anim)
humanoid.WalkSpeed = 0
playAnim:Play()
wait(1.5)
playAnim:Stop()
hunger.Value = hunger.Value + 5
script.Parent:Destroy()
humanoid.WalkSpeed = 16
enabled = true
end
end)
while true do
wait(60)
script.Parent:Destroy()
end

1 comment
That should be a comment ;p