I have a buy rank gui with a yes button among others but when i click yes it says 14:43:34.297 - ServerScriptService.Leaderstats:28: attempt to index upvalue 'stats' (a nil value)
14:43:34.297 - Stack Begin
14:43:34.298 - Script 'ServerScriptService.Leaderstats', Line 28
14:43:34.298 - Stack End idk what this means, someone pls help yes local script:
local rep = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Visible = false
script.Parent.Parent.no.Visible = false
script.Parent.Parent.Rank.Visible = true
--if game:GetService("Players").LocalPlayer.leaderstats.Money.Value >= 50000 and game:GetService("Players").LocalPlayer.Rank.Value == 0 then--i cut this part out because i didnt wanna have to have the money while testing
rep:WaitForChild("Rank"):FireServer()
--end--cut this part out to not have an end error since i cut out the if statement
end)
leaderboard script:
game.Players.PlayerAdded:Connect(function(player)
local stats = player:FindFirstChild("leaderstats")
local Key = "Player-ID:" .. player.UserId
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Money = Instance.new("NumberValue", leaderstats)
Money.Name = "Money"
game:GetService("ReplicatedStorage"):WaitForChild("Money").OnServerEvent:Connect(function()
stats.Money.Value = stats.Money.Value + game.Workspace.Base.Seller.seller.ironore1.Value.Value
end)
local Rank = Instance.new("NumberValue", leaderstats)
Rank.Name = "Rank"
game:GetService("ReplicatedStorage"):WaitForChild("Rank").OnServerEvent:Connect(function()
stats.Rank.Value = stats.Rank.Value + 1
end)
this is not the entire script but its enough to understand

7 comments
I can't read this
what?
I think he meant that he can't understand it
Put it in Lua form
? this is lua form
Idk if this is relevant, but you're trying to access leaderstats before you actually create the folder.
no the folder is created before, the leaderstat works i just cant manage to get the numbers in there to go up every time