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

Why after death points leaderboard gui got reset?

Hello, I have problem with points leaderboard gui, after death my gui show me 0, but still got all points. Here is main script from workspace:

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("IntValue",player)
	leaderstats.Name = "leaderstats"
	
	local points = Instance.new("NumberValue",leaderstats)
	points.Name = "Points"
	points.Value = 0
	
	local P = game.StarterGui.Points.Frame.Point
	P.Text = " "..points.Value
end)

Here is script from StarterGUI>Points>Frame>Point :

local Player = game.Players.LocalPlayer
local stats = Player:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")

function PointChange()
	script.Parent.Text = " "..points.Value
end

points.Changed:connect(PointChange)

Maybe i need add line somewhere, but i don't know where, becouse im beginner scripter. Here is GIF with my problem: http://gyazo.com/c99252551e5a5bf76dee3c3b0829b9a6

1 comment

0

Every time a player dies, the startergui is re-cloned into their playergui.

1 answer

✓ Accepted answer
local Player = game.Players.LocalPlayer
local stats = Player:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")
   script.Parent.Text = " "..points.Value -- Every time a player dies, the startergui is re-added to their playergui. Therefore, if this is added, when it is re-added to their playergui, it will display their current points instead of 0.

function PointChange()
    script.Parent.Text = " "..points.Value
end

points.Changed:connect(PointChange)

4 comments

0

But script in the Gui is Local Script.

0

okay, let me play around with the script.

0

So you tried something?

0

Thanks for help.

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