GUI Failing To Reappear After Tween?

  1. What do you want to achieve? Keep it simple and clear!

I’d like the GUI Frame to be tweened out of view smoothly when the user clicks “no”.

  1. What is the issue? Include screenshots / videos if possible!

When the user opens the GUI menu it is tweened into view smoothly. When the user clicks No it tweens out smoothly as well, when the user goes back and tries to open the GUI menu (via proximity prompt) it doesn’t work the second time.

Proximity prompt script to OPEN then menu. This script is inside the proximitypromp. It is a server script.

local activatorProx = script.Parent


activatorProx.Triggered:Connect(function(plr)
	local guiMenuFrame = plr:WaitForChild("PlayerGui"):WaitForChild("STOCK"):WaitForChild("Frame")
	print("activated")
	guiMenuFrame:TweenPosition(UDim2.new(0.279, 0, 0.736, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.6, true)

	--wait(2)

	--guiMenuFrame:TweenPosition(UDim2.new(0.278, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.6, true)
	
end)

This is the script inside the NO button which CLOSES the menu. it is a local script.

local button = script.Parent
local guiMenuFrame = script.Parent.Parent

button.MouseButton1Down:Connect(function(x, y)
	guiMenuFrame:TweenPosition(UDim2.new(0.278, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.6, true)
end)

I cannot find out why this is happening. I’ll respond asap tomorrow to any possible solutions. Thank you!

This is going to be quite a difficult explanation to follow if you don’t understand Client vs Server replication. If you don’t want to bother with the explanation, just skip to the end.

The GUI, I’m assuming, is initialized to the position UDim2.new(0.278, 0, 1, 0). This means that, on the server, this GUI is in that position.

When you activate the prompt, the server tweens the position of the GUI and updates its position as well ON THE SERVER. This is important.

When you click the button to close it on the client, it correctly tweens the button back into the hidden area (UDim2.new(0.278, 0, 1, 0))

HOWEVER, since this action was done on the client, the GUI’s position DOES NOT update back to the hidden position mentioned above (ON THE SERVER). The server does not see this position as changed, so when you attempt to change the GUI’s position back on the server to “open”, no changes are made to the server, so why would it try to update the client?

WHAT CAN YOU DO?
The way to fix this is to only perform GUI manipulation on the client. Either you handle the Prompt.Triggered on the client or fire a remote to the client to update the GUI as open.

1 Like

instead of using the server script to do tweenposition, make a remote event, call :FireClient(player) and then do the TweenPosition in the client

the problem is this: the server (Script) thinks that it’s in the open position alr because you close it on the client (LocalScript). on the server, nothing changed so it doesn’t do anything

Ohh I see. The remoteEvent method was the original method I was going to do since that is what every other of my GUI event tween thingies use. I’ll use the remoteEvent method instead. Thank you!

Also I appreciate and love the way you formatted and worded your response. It really made it easy for me to understand what I did wrong and how to handle similar problems later down the line! :heart:

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