Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

attempt to index local 'player' (a nil value). Help? (Solved)

So I am making a script that gives 10 KOs every 60 seconds. The wait(1) is a placeholder. Can someone help? Script: local player = game.Players.LocalPlayer wait(1) player.leaderstats.KOs.Value = player.leaderstats.KOs.Value + 10 * (player.leaderstats.ReKOs.Value + 1)

Edit: There is a line down before the wait(1) and player.leaderstats.

1 answer

You cannot use LocalPlayer on the server. You could use a remote event for example Server Script:

RemoteEvent.OnServerEvent:Connect(function(player)

end)

You do not need to use game.Players to start you would do "player.Character" for example

To fire this Remote you would use:

RemoteEvent:FireServer()

On the client

But in your case you would do this

local WaitTime = 1 
game.Players.PlayerAdded:connect(function(player)
	while true do
		wait(WaitTime)
	player.leaderstats.KOs.Value = player.leaderstats.KOs.Value +10
	end
end)

4 comments

0

Let me know if you need anymore help!

0

Also this is a server script in serverscriptservice

0

i have not tested this yet so it might not work

0

Thanks! It worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.