Gui not updating ;-;

so, when the player touches a part, a gui will appear and will display how many doors player has opened. But it doesn’t update it and always display 0.
help…

local script :

event.OnClientEvent:Connect(function(checked, total, text)
	local message = text .. "\n" .. checked .. "/" .. total

	local frame = script.Parent:WaitForChild("Frame")
	local text = frame:WaitForChild("Text")

	frame:TweenPosition(UDim2.new(0.883, 0, 0.5, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 0.3, false)
	text.Text = message
end)

script :

script.Parent.Touched:Connect(function()
	event:FireAllClients(valueChecks.Value, valueTotal.Value, "Open all doors!")
end)

Have you printed out the values on the server sided script to check the values before firing them? If not then the issue may just be with the Values not being updated beforehand.

Honestly not sure, but it probably isn’t great that you use an argument’s name as a new variable, “text” (With a lowercase ‘t’) I don’t think that’s generally a good idea.

1 Like

It works for me when I replicated your code, so it’s likely there’s no problem in the code you’ve shown.

First of all if you want to display the doors opened of just one player don’t use :FireAllClients(), instead use :FireClient()

Secondly try getting the text gui using PlayerGui.

IDK if these will solve your problem but it is worth trying

like this?

it won’t work with fireClient, and my loca script is located isnide a gui so i can access it directly… :smiley:

oh nevermind i have figured it out : i have to put :GetPropertyChangedSignal

script.Parent.Touched:Connect(function()
	local function changed()
		event:FireAllClients(valueChecks.Value, valueTotal.Value, "Open all doors!")
	end

	changed()

	valueChecks:GetPropertyChangedSignal("Value"):Connect(function()
		changed()
	end)
end)
2 Likes

You need to touch the part again most likely. If you touch the part that shows the gui, you would be able to see your changes reflected. I think you would like it if it updated automatically though, so in order to do that, use
local function OnValueChanged()
(update gui)
end

Value.GetPropertyChangedSignal:Connect(OnValueChanged)

1 Like

You got it! You can simplify what you have there by doing this:

script.Parent.Touched:Connect(function()
valueChecks:GetPropertyChangedSignal(“Value”):Connect(function()
event:FireAllClients(valueChecks.Value, valueTotal.Value, “Open all doors!”)
end)
end)

1 Like

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