Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with adding points to leaderboard script?

Asked by
F_lipe 135
9 years ago
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

0
Is your script a LocalScript? Only LocalScripts can use LocalPlayer. TheDeadlyPanther 2460 — 9y
0
Changed it to local script and now nothing happens, the script doesn't error, but it doesn't work either. F_lipe 135 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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
Ad

Answer this question