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?
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.