This is an interesting question. It would be relatively simple to implement this incorrectly, but requires a bit of a process to do it the correct way. Since we want to comply with FilteringEnabled, the following method is the best.
First of all, create your GUI in StarterGui. Then, put a RemoteEvent in it, called "Show". On the same level, include a LocalScript. Your hierarchy structure should look like this:
- StarterGui
-
-
-
- TextLabel (This is the GUI we will be showing)
-
-
Inside of your brick, insert a Script.
RemoteEvents allow you to send data from the Server to the Client, and vice-versa. This is very useful when FilteringEnabled is enabled!
Inside the brick script, include the following:
01 | script.Parent.Touched:connect( function (p) |
03 | if not p.Parent then return end |
05 | local player = game.Players:playerFromCharacter(p.Parent) |
07 | if not player then return end |
09 | player.PlayerGui.ScreenGui.Show:FireClient() |
Now, what the above code will do is check whatever touches the part is a player, and if so, try to fire the RemoteEvent inside of the GUI.
Now, inside of the LocalScript (which is in the GUI), we will use this code:
01 | local gui = script.Parent.TextLabel |
03 | script.Parent.Show.OnClientEvent:connect( function () |
04 | if working then return end |
08 | gui.BackgroundTransparency = i |
09 | gui.TextTransparency = i |
14 | gui.BackgroundTransparency = i |
15 | gui.TextTransparency = i |
When you put all of this together, you should get a button that properly fades in a GUI when a player touches the part.