How do I make a GUI appear when stepping on a part?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! (I want to make some dialogue GUI appear on the screen when stepping on a part, and want to keep it on screen for at least 15 seconds after stepping on the part)

  2. What is the issue? Include screenshots / videos if possible! (I just don’t know how, I really am new to scripting, if this helps this is the GUI I want to enable/disable)image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? (As I said I don’t know many scripting so I couldnt even try to solve it as I would be a headless chicken looking for its nest.)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Put this script in the part they will touch

script.Parent.Touched:Connect(function(obj)
local h = obj.Parent:FindFirstChild("Humanoid")
if h then
game.Players[h.Parent.Name].PlayerGui.PonyDialog.Enabled = true -- So all of the frames in it appear at once
end
end)
2 Likes

This works as a debounce but the connection still gets fired every time you step on the part. For better performance, I would utilize an outer scope debounce with :Disconnect to disconnect the Touched connection.

true should have put a debounce in there but i didnt because if a player who hasnt touched it touches right after someone else the part wouldnt work for the second player

Yeah, while testing i realized that not only does it stay with you until you oof, but passing through the part again triggers it, however it would be pretty simple to fix the first problem, adding a part that just sets the GUI to be disabled whenever I would like the part to stop being visible

Instead of checking for a Humanoid, you could try getting the player by doing Players:GetPlayerFromCharacter().

Yeah but the thing is Players:GetPlayerFromCharacter() never works for me :confused:

1 Like

This won’t be a problem however, as my game is planned to be single player or just allow two players

Anyways I believe the two issues the script presents has a way to fix it i can figure out by myself, so ill just mark the script as the solution, thanks for the help to all of you.

No problem! also i would recommend before making a topic try to look it up on the dev forum first!

I’m a bit late, but I advise using remote events, so when you step on a part, it fires that event to the client.

Make sure you have a script that will pick up when the event is fired, making the GUI enabled.

Hello I tried this script but for some reason when i close the gui and then walk back on the part it doesent reneable the gui.