When I use this in studio, it works. When I play the game normally, the leaderboard is not there and it does nothing when I die. Please tell me what I did wrong, thank you.
Player = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function(Player)
local stats = Instance.new("IntValue")
stats.Parent = Player
stats.Name = "leaderstats"
local Points = Instance.new("IntValue")
Points.Parent = stats
Points.Name = "Pointz"
deaths = Instance.new("IntValue")
deaths.Parent = stats
deaths.Name = "Deaths"
game.Players.LocalPlayer.CharacterAdded:connect(function()
game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local deathGui = Instance.new("ScreenGui")
deathGui.Parent = game:GetService("Players").LocalPlayer.PlayerGui
local deathText = Instance.new("TextBox")
deathText.Parent = deathGui
deathText.Text = "YOU SUCK, "..game.Players.LocalPlayer.Name
deathText.FontSize = "Size96"
deathText.Position = UDim2.new(0.5,0,0.5,0)
deathText.BackgroundTransparency = 1
deathText.TextColor3 = Color3.new(255,255,255)
wait(5)
deathGui:Remove()
end)
end)
end)

4 comments
Is it in a normal script or a local script?
As you are using "LocalPlayer" I assume that this is a local script. You are trying to mix server events with local ones. You need to 1st use a server sctipt for adding the leaderstats nad re-think how the gui side will work.
This is a normal script, not a local script
Only local script have acces to localplayer so thats half of the problem....