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

this script attempt to index nil? how can I fix this?

I get an error attempt to index nil. how to fix this?

server sided script:

local player = game.Players.LocalPlayer

if player.leaderstats.Value.Money > 12000 then
player.leaderstats.Value.Money = player.leaderstats.Value.Money - 12000
player.PlayerGui.ScreenGui.TextLabel.Text = "Purchased!"
end

1 answer

✓ Accepted answer

Try:

player = game.Players.PlayerAdded:Connect(function(player)

if player.leaderstats.Value > 12000 then
player.leaderstats.Value = player.leaderstats.Value -12000
player.PlayerGui.ScreenGui.TextLabel.Text = "Purchased!"

end)

LocalPlayer cannot be used on a server sided script, only local.

If I helped, please mark this answer as solved! We both will get a reward!

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