I've been trying to give the player the tool who lowered the value to 0, but it won't work.
local wood = game.ServerStorage.WoodStorage.Wood local hits = script.Parent.Hits part = script.Parent player = script.Parent.Parent.Parent.Parent timber = false while wait() do if hits.Value < 1 and not timber then timber = true part:Destroy() wood:clone().Parent = player.Backpack end end
Error: Line 11, attempt to index global 'player' (a nil value)
Ok, so to get a Player from inside a ServerScript, their are multiple ways to get the player. Now I can see you used player = script.Parent.Parent.Parent.Parent
which makes me believe that you have the script inside the StarterPack or StarterGui. If so, then this should be an easy fix. All you have to do is make sure that you are getting the player and not some other random thing. I would suggest using print(player)
underneath where you got all the variables;
local wood = game.ServerStorage.WoodStorage.Wood local hits = script.Parent.Hits part = script.Parent player = script.Parent.Parent.Parent.Parent timber = false print(player)
You can then check the output and see what was printed. If it prints the players name then it should work, but if it prints anything else, then you haven't got the player, and you might need to add or take away a few .Parents
inside the player variable.
If your script ISN'T inside either the StarterPack or StarterGui, then you have to get the player a different way.
But for this, I would suggest that you make sure it is in the StarterPack or StarterGui, and make sure that you got the player, and not something inside the player.
Hope this helped and be sure to +1 and accept answer.
If this didn't, then please reply back with what the print(player)
printed in the output and I can help you out.