ValueName.Changed not working occasionally

When the players xp, level and/or cash changes it should update for the player on their GUI. Most of the time it works. However, sometimes it doesn’t update when it should. I get no errors or yields, nothing in the output. It’s fairly simple code…

pfolder.xp.Changed:Connect(function()
	frame.main.xp.Text = tostring(abbv(pfolder.xp.Value).."/"..abbv(pfolder.Level.Value*73))
	frame.main.Frame.Frame.Size = UDim2.new(pfolder.xp.Value/(pfolder.Level.Value*73),0,1,0)
end)

I’ve tested it without the code inside it and replaced it with print(“Updated”)

In what cases this does not work? Because Changed event is a tested built-in feature and works all the time. The problem is probably caused by the way you change the value, for example if you’re changing a server value using a Local Script and filtering is enabled then the server won’t notice the change and the event will not fire.

1 Like

So I have the player stats in serverstorage, and player stats in replicated storage. When the server storage stats change, the replicated update. When the replicated update/change the gui changes too.

1 Like

But you have to specify what updates these values, because sometimes you might be updating them manually in studio to test if everything works and suddenly it doesn’t becuase you’re in the ‘local view’ and you have to switch to the ‘server view’ to make global changes instead of local changes as local changes are not replicated to the server.

You provided too little information about the use case when the event is not fired.

1 Like

I tested it ingame. With kills and an auto giver. It would change the values via ServerStorageStats and ReplicatedStorageStats. After the ReplicatedStorageStats are updated, the gui should update. The values are always changing, I know that from printing out the values in command prompt ingame. But sometimes the GUI doesn’t update.

Okay so I found out that the reason the GUI wont update is because the ReplicatedStorageStats wont update when the ServerStorageStats update. Yet, for some reason I get no error or anything in output regarding the Changed Event.

local spfolder = game.ServerStorage.PlayerStats:WaitForChild(player.UserId)
	local scoin = spfolder:WaitForChild("Coin")
	local sxp = spfolder:WaitForChild("xp")
	local sLevel = spfolder:WaitForChild("Level")
	local sWeaponsOwns = spfolder:WaitForChild("Owned")
	for i,v in pairs(sWeaponsOwns:GetChildren()) do
		WeaponsOwns[v.Name].Owns.Value = v.Owns.Value
	end
	for i,v in pairs(sWeaponsOwns:GetChildren()) do
		v.Owns.Changed:Connect(function()
			WeaponsOwns[v.Name].Owns.Value = v.Owns.Value
		end)
	end
	Coin.Value = scoin.Value
	scoin.Changed:Connect(function()
		Coin.Value = scoin.Value
	end)
	xp.Value = sxp.Value
	sxp.Changed:Connect(function()
		xp.Value = sxp.Value
	end)
	Level.Value = sLevel.Value
	sLevel.Changed:Connect(function()
		Level.Value = sLevel.Value
	end)
1 Like