Still have questions? Join our Discord server and get real time help.
1

# Updating GUI without resetting character?

J_98482 18
5 months ago

I'm trying to get one of my GUI elements to display a number counter, but the number itself won't update unless the player character dies or is reset. I've tried having disabling the GUI and re-enabling right after, but that didn't seem to help. What can I use to have the GUI update the value without forcing the player to reset their character? Thanks in advance to anyone who helps out.

Here's what I have code-wise. It's not much, but it's all I have for now. the 'update' local is pointing to a RemoteEvent that should have, in theory, forced the GUI to update. The 'number' value is also working correctly.

local player = game.Players.LocalPlayer
local number = game.ServerStorage.credits[tostring(player.Name)]Value
local update = game.ReplicatedStorage.creditupdate

update.OnClientEvent:Connect(function()
script.Parent.Text = "You currently have "..number
end)


0
I would delete the .Value on line 2, and use number.Changed:Connect to actually update it, depends on what you want to do though RedcommanderV2 1253 — 5mo
0
Yes, I wouldn't use server storage to store something supposed to be accessed by the client, unless you want to sent the value through a remote event theking48989987 1767 — 5mo

0
Edited 22 days ago

On line two, remove Value. And then you can instead of using a client event you can use object:GetPropertyChangedSingal("Value") object is the credits object. Because this is a localscript, you can not access the ServerStorage from the client, so I would recommend changing it to ReplicatedStorage. There is also no need for tostring on the name since it's already a string value. So you could do:

local player = game.Players.LocalPlayer
local number = game.ReplicatedStorage.credits[player.Name]

number:GetPropertyChangedSingal("Value"):Connect(function()

script.Parent.Text = "You currently have "..number.Value --if number is a numberValue you will have to use tostring here

end)