Here are my scripts
Leaderstats script
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local rng = Instance.new("IntValue")
rng.Name = "Rng"
rng.Value = 0
rng.Parent = leaderstats
end
Players.PlayerAdded:Connect(leaderboardSetup)
Give points script
local part = game.Workspace.MyButton
clickDetector = game.Workspace.MyButton.ClickDetector
clickDetector.MouseClick:Connect(function(onClick)
amount = math.random(1,10000)
game.Players.LocalPlayer.leaderstats.Rng.Value = game.Players.LocalPlayer.leaderstats.Rng.Value + amount
print(amount)
end)
The error
Workspace.MyButton.ClickDetector.Script:6: attempt to index nil with 'leaderstats'
So what I'm doing is going into the the player with game.player then the localplayer then the folder leaderstats and then the intvalue rng. But it keeps getting this error. Idk what to do.
** You are now Level 3! **