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()
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()
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.