Help with GUI showing when a part is touched

Hello, I am a solo Roblox Dev who doesn’t have much ability in the realm of scripting. I am trying to make a GUI appear when a player touches a part, I know this probably seems simple to most but I just can’t seem to figure it out. I have spent around 2 hours trying to figure it out on my own, and have watched a few tutorials/ read dev forum posts. So it would mean a lot if somebody could help teach me how to do this task I would appreciate it greatly.


You can get the players name when the part is touched. You then can use


Something like that, and then you copy the gui to their player gui.

1 Like

Something like:

local part = game.workspace.Part -- replace with pathway to your part
local GUIFrame = script.Parent -- replace with pathway to your Frame. I shoudl note that this example is a local script;
local db = false --We make a debounce, as Touched can fire a lot at once. This is used like a cooldown
part.Touched:Connect(function(Hit) -- We listern if the part has been touched
if db == false and GUIFrame.Visible == false and game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(Hit.Parent) then -- We check the cooldown and they we have the right player.
db = true
GUIFrame.Visible = true --Cooldown is active and frame visible
db = false
GUIFrame.Visible = false --Cooldown is active and frame invisible

--This is a basic setup for something like this, and you can do it many different ways!

Hope this helps!

1 Like

Thank you everybody for the help, I will try this first thing tomorrow. (I’ve lost all energy to work on the game for tonight😅)

This is POG_CAT’s script but just more refined.
Put this in a script and in your part.
Put your gui into the script and edit the values.

local TouchPart = script.Parent -- The part that is going to be touched 😲
local UI = script.GUI -- Put your GUI

	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if not plr.PlayerGui:FindFirstChild("PUT YOUR GUI NAME HERE") then
			local clone = UI:Clone()
			clone.Enabled = true
			clone.Parent = game.Players:GetPlayerFromCharacter(hit.Parent)

Thank you very much I’ll try this tomorrow.

1 Like

Here’s an example easy LocalScript that you can parent under your UI.
Make sure the UI is not enabled at first.

local Part = game.Workspace.Part -- Enter your part location
local YourUI = script.Parent -- Enter your UI's location

Part.Touched:Connect(function(hit) -- When the part's .Touched event gets fired, we catch that and connect it to a function. The "hit" is the part that touched the part that you wanted to be touched.
   if not hit.Parent or not hit.Parent:FindFirstChild("Humanoid") then return end -- Checking if the hit part actually belongs to a character

   local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player object from the character
   if not game.Players.LocalPlayer == player then return end -- Checking if the player that touched the part is the current player
   UI.Enabled = true -- Enabling the UI
1 Like