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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

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)
0
Let me know if you need anymore help! Instance_Brick 12 — 4y
0
Also this is a server script in serverscriptservice Instance_Brick 12 — 4y
0
i have not tested this yet so it might not work Instance_Brick 12 — 4y
0
Thanks! It worked. iiDkOffical 109 — 4y
Ad

Answer this question