Why is this happening? (SurfaceGui Script)

Can you try changing all the waits with a Tween?

Using TweenService, tween the ImageTransparency property from 0 to 1 (and vice versa).

He tried getting rid of the waits and the same issue persisted. It doesn’t have anything to do with the waits.

Same issue. It works the first time, not the second.

Another possibility is that this is a studio bug. Try this in-game and see if maybe it works.

Nope, it doesn’t work in game either.

I just noticed this, but why are you using a server script for tweening (entering)? It is recommended to tween GUIs using local script. It may not be related to your issue, but maybe switch to a local script?

Have you tried this? It could have something to do with TweenService

Yes, I tried it and the same issue happened. It worked the first time, not the second.

Ohh you might be right. It seems like he is tweening the frame IN with a serverscript but tweening it OUT with a localscript

Oh I think I know why now. It’s because of how two different unique script controls the UI.

In the server, you tweened the Functions frame to the position (0, 150, 0 ,0) which would replicate to all clients to change their UI.

In the client, you tweened the Functions frame back to the original position (0, 0, 0, 0), but the server sees that it is not in the position (0, 0, 0, 0).

The reason why it doesn’t tween the second time is because the server sees that the Functions frame is not back to its position (0, 0, 0, 0), so it doesn’t tell the client to change anything.

Should I combine both the enter and exit scripts? If so, should I combine them into the server script (surfacegui) or the client script (screengui)?

Not EXACTLY, but you’re on the right track. Once the client overrides something the server did, it will stop replicating.

@zimids I suggest using a local script so the server doesn’t increase its workload.

@Volieb Can you tell me what you mean by not exactly?

You were right, you just didn’t word it correclty. That’s all :grin:

1 Like

I combined them into the LocalScript, now the Functions frame doesn’t tween away after the GUI button is clicked. The logo doesn’t appear either.

local Logo = script.Parent.Parent.Parent.Parent.Screen.SurfaceGui.Frame.Logo
local LogoFrame = script.Parent.Parent.Parent.Parent.Screen.SurfaceGui.Frame
local Functions = script.Parent.Parent.Parent.Parent.Screen.SurfaceGui.Functions
local GuiButton = game.StarterGui.Menu.Exit.TextButton

script.Parent.MouseButton1Click:Connect(function()
	wait(0.5)
	script.Parent.Visible = false
	wait(0.5)
	Logo.ImageTransparency = 0.1
	wait(0.01)
	Logo.ImageTransparency = 0.3
	wait(0.01)
	Logo.ImageTransparency = 0.7
	wait(0.01)
	Logo.ImageTransparency = 0.9
	wait(0.01)
	Logo.ImageTransparency = 1
	LogoFrame.Visible = false
	wait(1)
	Functions:TweenPosition(UDim2.new(0, 0, 0, 0),"Out","Quart",0.5)
end)

GuiButton.Activated:Connect(function()
	Functions:TweenPosition(UDim2.new(0, -150, 0, 0),"Out","Quart",0.5)
	wait(1)
	LogoFrame.Visible = true
	Logo.ImageTransparency = 0.9
	wait(0.01)
	Logo.ImageTransparency = 0.7
	wait(0.01)
	Logo.ImageTransparency = 0.3
	wait(0.01)
	Logo.ImageTransparency = 0.1
	wait(0.01)
	Logo.ImageTransparency = 0
end)

This is because LocalScripts don’t run in Workspace.

Like I said in my first reply, consider using the method I explained in this thread:

1 Like