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

Help with adding points to leaderboard script?

local player = game.Players.LocalPlayer
while true do
	
	wait(20)
	player.leaderstats.Points.Value=player.leaderstats.Points.Value+20
end


output: 15:41:49.796 - ServerScriptService.overtime:5: attempt to index local 'player' (a nil value) 15:41:49.797 - Stack Begin 15:41:49.797 - Script 'ServerScriptService.overtime', Line 5 15:41:49.797 - Stack End

2 comments

0

Is your script a LocalScript? Only LocalScripts can use LocalPlayer.

0

Changed it to local script and now nothing happens, the script doesn't error, but it doesn't work either.

1 answer

✓ Accepted answer

Try putting this in a ServerScript in StarterPack or StarterGui.

local Player = script.Parent.Parent -- Converted from game.Players.LocalPlayer.
local Stats = Player:WaitForChild("leaderstats") -- Waits to continue until leaderstats are loaded

while wait(20) do -- You can convert "while true do wait(20) end" to "while wait(20) do end".
	Stats.Points.Value = Stats.Points.Value + 20
end

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