I want to make a GUI popup when a player touches a specific brick.
I'm finding a lot of trouble with the positioning of the GUI frames but that is not what I need help with. When the player touches the brick, a text will popup on the screen for (3) seconds, and then disappear.
I remember trying to do this without help but did not succeed and the GUI just doesn't pop up, I removed the script shortly after because I could not find the reason why it did not work so I can't paste it in here.
The player is not allowed to skip the text and will have to wait for the GUI to disappear in the (3) seconds.
I hope that my explanation is clear enough and that I am not confusing anyone, just in case more explanation is needed, please use the comments section and I'll try to answer as fast as possible! Any help is very appreciated.
(insert something funny here)
hi lemme help
You want to use remote events.
To start of, create a RemoteEvent in ReplicatedStorage, make sure to name it: "PopupGuiEvent"
Now lets get into scripting it!
First of, inside the part, make a server script and insert the following code into it!
If this helped you, please mark this as the answer!
Server Script
local event = game:GetService("ReplicatedStorage"):WaitForChild("PopupGuiEvent") script.Parent.Touched:Connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then event:FireClient(plr) end end)
Now make a local script inside StarterGui, and then insert the following code into it.
Local Script
local event = game:GetService("ReplicatedStorage"):WaitForChild("PopupGuiEvent") local gui = script.Parent.PopupGui.Frame local db = false event.OnClientEvent:Connect(function() if not db then -- If db is false, the script will run the next bits of code gui.Visible = true db = true wait(3) gui.Visible = false db = false end end)
You can do this either two ways: Both ways require you to use a bricks touch event. Mind the lack of code. I'm on my phone so I can't write well. Second method is more complicated but it's good for doing more advanced things to the gui.
1) Create a touch event that does the following: 2) get the players gui inside the player
(Not sure where it is off the top of my head but you can see it's location when you press play and look at the players in the explorer.)
3) Next, change the guis visible property to true
4) Wait(3)
5) Make the gui's visible to false.
1) Create a touch event that does the following:
2) Fire a remote event called showGui
3) In a local script inside the gui, have a function that runs when the remote event is fired:
4) Inside the function make the gui visible
5) Wait(3)
6) Make it invisible again