Surface GUI Button Not Working (Not Your Usual Copy Paste Topic)

I am going to be honest, I’ve read all the topics that there is about this problem but none exactly suits my system. I tried the Adornee thing and checked the Active properties but none of them seem to work. This is 99.9% not a problem with scripting, as I have checked the script 100 times and asked the Scripting Support part of Help and Feedback.

My goal is simple. Click the button, do some stuff I want, disable the current Surface GUI, enable different Surface GUI, click the button, do some stuff I want, and so on.

The Adornee solution I don’t seem to understand, it works for others but the thing is that I have to enable that GUI and I am unsure how to do that. I’ve tried in a local script going to Starter GUI and getting it but that did not work.

I appreciate all of your contributions, I will be checking this topic often. Remember, every comment helps! Thank you for all of your support! :slight_smile:

1 Like

Don’t do game.StarterGui, it doesn’t exist in running games!
start from the LocalScript to find your GUI object.
(ex: script.Parent.GUI)

Where’s my 100$?

EDIT: Could I see your script and explorer window?

1 Like

Hey there, sorry about that haha, made a small typo.

The Surface GUI for some reason stays in Starter GUI, so nothing is happening, unsure why

image
image

script.Parent.MouseButton1Click:Connect(function()
	print("wow done")
	local part = game.Workspace.CameraPart
	local TweenService = game:GetService("TweenService")

	local tweenInfo = TweenInfo.new(
		0.1, --Time
		Enum.EasingStyle.Linear, --Easing Style
		Enum.EasingDirection.Out --EasingDirection
	)

	local tween = TweenService:Create(part, tweenInfo, {Position = game.Workspace.target2.Position})
	tween:Play()

	game.Workspace.places.camm2.SurfaceGui.Enabled = false
	game.Workspace.places.cammm2:WaitForChild("SurfaceGui").Enabled = false
	TweenService:Create(
		game.Lighting.Blur, 
		TweenInfo.new(0.2), 
		{Size = 56} 
	):Play() 
	task.wait(0.6)
	game.Workspace.places.camm3.SurfaceGui.Enabled = true
	game.Workspace.places.cammm3.SurfaceGui.Enabled = true
	TweenService:Create(
		game.Lighting.Blur, 
		TweenInfo.new(0.2), 
		{Size = 0} 
	):Play() 


end)

edit: added the mousebutton1click function, devforum cut it out for some reason

It stays in StarterGUI, but it gets copied to your PlayerGUI.
Does part of your code work?

So how could I access it? Do I have to convert my server script to a local script to access it?

That is weird, because it works

Basically at the start of my whole click button do the effects and things i want to do then disable and enable loop I used the exact same script, and it works, just at the second time of this whole loop it mysteriously doesn’t work

Oh I just saw it, you cant use Scripts on the client.
Copy the code in a LocalScript

I did convert it, but still, how can I access PlayerGUI? I have an assumption already but just making sure I don’t make another mistake

Well you can use script.Parent.
This would select the TextButton that the script is in.

Also I just saw another mistake, But you can’t use SurfaceGUI in StarterGui.
It’s only for parts.

I am a bit confused right now,

All previous topics of this same question link to one solution: Put the GUI in StarterGUI, set the GUI’s Adornee to the part, in studio if I do everything and set it to enabled, the GUI shows perfectly fine, and I meant accessing the GUI in a different script (in the workspace)

1 Like

Yes buut you need to convert your SurfaceGUI to a ScreenGUI, or else it won’t show up.

But then it wouldn’t display on the part anymore…

And to acces the GUI from the workspace, well… You can’t.
You’ll have to use RemoteEvents that tells the client where to put GUIs.

Oh I’m sorry I thought it was in StarterGui please ignore it.

No, it is in StarterGUI, that’s the whole thing, I explained it in this comment

2 Likes

Oh okay!
I was confused.

Could you please explain what you want to do, but what does work again please? I’m really sorry!

1 Like

Can’t you do something like in a local script that you get the localplayer, get the playergui and just access it from there? Or is the playergui stored somewhere where a local script can’t access it

2 Likes

Yes, you can with the Players service. I avoided it as it would be clunky.

But you can use script.Parent.Parent.Parent instead to access the SurfaceGUI.

1 Like

My goal as explained in the start is to:

2 Likes

No, I want it to be accessed from a different script which is not the parent of the GUI

2 Likes