I want to make a rank system for my roblox game. It checks what the name of the local player is and puts something else in the leaderboard. This is the script:
local lplayer = game.Players.LocalPlayer
local leaderstats = Instance.new("StringValue")
leaderstats.Name = "Rank"
leaderstats.Parent = lplayer.leaderstats
while true
do
if lplayer.Name == "blocky010101" then
leaderstats.Value = "Owner"
elseif lplayer.Name == "Clone3650" then
leaderstats.Value = "Tester"
else
leaderstats.Value = "Player"
end
end
But in output it comes up with this:
ServerScriptService.Script:5: attempt to index local 'lplayer' (a nil value)
why does this happen?

1 comment
Thankyou so much!