Gui is not updating (RemoteEvent, IntValue)

You can write your topic however you want, but you need to answer these questions:

I want the GUI to update every time the value changes in the remoevent (intvalue)

It does not update even tho the value changes.

There is the SurfaceGUI (TextLabel) that I wanna update every time the intvalue in the remoteevent changes

Here is the code the code is placed in the ServerScriptService

local DataStoreService = game:GetService("DataStoreService")
local NumberDataStore = DataStoreService:GetDataStore("NumberDataStore")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateNumberEvent = ReplicatedStorage.UpdateNumber

local function updateNumber(player, number)
	local success, error = pcall(function()
		NumberDataStore:SetAsync("Number", number)
	end)
	if not success then
		warn("Failed to save number:", error)
	end
end

UpdateNumberEvent.OnServerEvent:Connect(updateNumber)

local function playerAdded(player)
	local success, number = pcall(function()
		return NumberDataStore:GetAsync("Number")
	end)
	if success then
		UpdateNumberEvent:FireClient(player, number)
	else
		warn("Failed to retrieve number:", number)
	end
end

game.Players.PlayerAdded:Connect(playerAdded)

local function updateText()
	local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
	local numberValue = displayValues:WaitForChild("Number")
	local textLabel = game.Workspace.JermyStandSignRaised.SurfaceGui.Frame.Number -- Reference to your TextLabel GUI object
	textLabel.Text = numberValue.Value
end

local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
local numberValue = displayValues:WaitForChild("Number")
numberValue.Changed:Connect(function()
	updateText()
end)

updateText()
3 Likes

Can you share the scripts that are actually changing the value?

2 Likes

Try using :GetPropertyChangedSignal(), so

numberValue:GetPropertyChangedSignal("Value"):Connect(updateText)

If this doesn’t work, put a print function inside of the function and see if it prints when the number value is suppose to change.

2 Likes

The only script that updated is the script I wrote in the page up there

1 Like

Hm its strange it does not even print the value…
Even tho the intvalue.value changed

1 Like

This is the new written script with the :GetPropertyChangedSignal(“Value”) function.

local DataStoreService = game:GetService("DataStoreService")
local NumberDataStore = DataStoreService:GetDataStore("NumberDataStore")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateNumberEvent = ReplicatedStorage.UpdateNumber

local function updateNumber(player, number)
	local success, error = pcall(function()
		NumberDataStore:SetAsync("Number", number)
	end)
	if not success then
		warn("Failed to save number:", error)
	end
end

UpdateNumberEvent.OnServerEvent:Connect(updateNumber)

local function playerAdded(player)
	local success, number = pcall(function()
		return NumberDataStore:GetAsync("Number")
	end)
	if success then
		UpdateNumberEvent:FireClient(player, number)
	else
		warn("Failed to retrieve number:", number)
	end
end

game.Players.PlayerAdded:Connect(playerAdded)

local function updateText()
	print("Updated. Should be I hope")
	local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
	local numberValue = displayValues:WaitForChild("Number")
	local textLabel = game.Workspace.JermyStandSignRaised.SurfaceGui.Frame.Number 
	textLabel.Text = numberValue.Value
end

local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
local numberValue = displayValues:WaitForChild("Number")
numberValue:GetPropertyChangedSignal("Value"):Connect(function()
	print("Updated. Should be I hope")
	local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
	local numberValue = displayValues:WaitForChild("Number")
	local textLabel = game.Workspace.JermyStandSignRaised.SurfaceGui.Frame.Number
	textLabel.Text = numberValue.Value
end)

updateText()
1 Like

Here is the model with all the assets.
So its easier for you and me

roblox_problem_gui.rbxm (46.3 KB)

1 Like

Alright, so your solution is to put the SurfaceGui onto the StarterGui and set the Adornee to the part where the SurfaceGui was originally at. The reason why this wasn’t working is because LocalScripts do not work in the workspace, only Server Script.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.