local Players = game:GetService("Players")
local LocalPlayers = Players.LocalPlayer.PlayerGui
Players.PlayerAdded:Connect(function(player)
if player then
local folder = Instance.new('Folder')
folder.Name = 'leaderstats'
folder.Parent = player
local coins = Instance.new('IntValue')
coins.Name = 'Coins'
coins.Parent = folder
coins.Value = 0
local rank = Instance.new('StringValue')
rank.Name = 'Rank'
rank.Parent = folder
rank.Value = player:GetRoleInGroup(950346) --Used Frappé as an example as I don't have a group yet.
end
end)
local CoinAmount = LocalPlayers.LeaderStats.TextLabel
Players.PlayerAdded:Connect(function(player)
while true do
CoinAmount.Text = tostring(Players.leaderstats.Coins.Value)
wait(0.5)
end
end)
Error I'm getting: ServerScriptService.LeaderBoard:2: attempt to index nil with 'PlayerGui' - Server - LeaderBoard:2
What is wrong with the script?
