:GetPropertyChangedSignal() not working

Hello. The following script does not entirely work:

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local Rank = leaderstats:WaitForChild("Rank")
local playerRank = Rank.Value

local setText = "Rank: "

script.Parent.Text = setText..playerRank

Rank:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = setText..playerRank
end)

Line 8 does work, the TextLabel updates to the player’s leaderstat upon entry to the game. However, the problem lies in lines 10-13 as the TextLabel does not update when the leaderstat value changes.

Any help is appreciated.

You never update playerRank so it’ll be the same every time.

It will only detect changes after you first change the text in this situation. Try changing it in a playtest after everything loads (on the server).

just do

Rank.Changed:Connect(function()
	script.Parent.Text = setText..playerRank
end)

this is what I always do and this works.

2 Likes

That’s the same thing, GetPropertyChangedSignal just detects a specific property instead of all of them

@CaptainWeetabix, you’d want to do something like this:

Rank:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = setText .. Rank.Value -- gets the new value
end)

I didnt notice he only called rank.value once in a variable, good catch!

actually Rank.Changed should do the exact same thing as this

Rank is a ValueBase so when you use Changed it will only run if the Value property was changed

1 Like