Player Gui Stage number dosen't changing

local Gui = script.Parent -- If the script is parented in the gui
local Number = game.Players.LocalPlayer.leaderstats.Stage.Value
	--or 

Number.Changed:Connect(function()
	
Gui.Text = Number.Value
end)

image

i did that and its erroring that attepmt to index number with changed

Erase the .Value from the end of your number variable

it should be:

local Gui = script.Parent -- If the script is parented in the gui
local Number = game.Players.LocalPlayer.leaderstats.Stage

Number.Changed:Connect(function()
	
Gui.Text = Number.Value
end)
1 Like

Oh sorry, this a leaderstat.

local Stage = game.Players.localplayer.Leaderstats:WaitforChild("StageNumber")
local Gui = script.Parent

function Update()
   Gui.text = Stage.Value
end

Stage.Changed:Connect(Update)
1 Like

yes i did that and it work but now when player exiting the game and joining the gui value is 0 untill he touch the next checkpoint.

for example the player was stage 6 and the left the game after time he back and he still stage 6(because i have datasave) but the gui showing 0

You we’re right it’s just that he added .Value when for the changed event it doesn’t use .Value

You need to use datastore to save the leaderstats data

i have already but the gui not saving the data

the stage is saving and when player come back to game he still in the same stage he was last time but the gui’s text is 0 untill he touch other checkpoint and then the number on the gui will be the stage number

So add this to your local script:

game.Players.PlayerAdded:Connect(function(player)
Gui.Text = player:WaitForChild("leaderstats"):WaitForChild("Stage").Value
end)


first image is when the player only spawned

the second one is after he touched the next stage

This will make it so it will update the text to the players stage number when they join

Did you try adding what I suggested

oh sorry i will try now i was writing to you something

where add that? in the local script?

its not working still when i join the gui value is 0 and only when i touch next checkpoint it changing to current stage value

Add a new Script in ServerScriptService like this:

game.Players.PlayerAdded:Connect(function(player)
	local Gui = player.PlayerGui:WaitForChild("ScreenGui").TextLabel
	Gui.Text = player:WaitForChild("leaderstats").Stage.Value
end)

Make sure that you change “ScreenGui” to the name of your screen gui and “TextLabel” to the name of your text

1 Like

working thank you very much you helped me a lot

thank you very much you helped me a lot too

1 Like

No problem. Just glad that I was able to help