Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why Does this Script with My SurfaceGui Not Work in FilteringEnabled?

Upon joining the game, a script waits for the player's Character to load and then adorns a SurfaceGui that is placed into his or her StarterGui beforehand to a part in the Workspace.

The script inside of the SurfaceGui which is in the Player's StarterGui:

repeat wait() until script.Parent.Parent.Parent.Character ~= nil
script.Parent.Adornee = game.Workspace.StartMenuArea.Room.Board

There is another script within it; an ImageButton in the SurfaceGui holds it. Upon clicking the ImageButton, it should print "Clicked."

The script inside of the ImageButton:

script.Parent.MouseButton1Click:connect(function()
	print("Clicked")
end)

When I test the game, the SurfaceGui is successfully adorned to the part in the Workspace. However, when I click on the ImageButton, "Clicked" is not printed. This confuses me because I thought that when FilteringEnabled was on, you didn't have to worry about using RemoteEvents and RemoteFunctions for the player's GUI, because it is client-sided. So why is this happening?

5 comments

0

I already tried setting the ZIndex of the button to 10, and yet nothing changed.

0

Try game.Players.LocalPlayer.CharacterAdded:wait() instead of your repeat until

0

I just did, and it didn't change anything.

0

A SurfaceGui would need the events connected using a local script then using a remote to process the users request.

0

But why would I need to use remotes at all if the SurfaceGui is client-sided?

1 answer

✓ Accepted answer

Client cant access workspace!

Notes:

  • Use game.Players.LocalPlayer instead of script.Parent.Parent.Parent.Character,
  • I prefer using :WaitForChild() function,
  • Do the same thing on server side so it should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.