Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can some someone explain to me how to make an onTouch event for a ScreenGUI to pop up when touched?

I am trying to make a onTouch event, but the only line I can remember is:

onTouch

When the part is touched??? Can I have some help please???

2 comments

0

No, when you touch it with your character.

0

Yes

2 answers

✓ Accepted answer

So screen GUIs hold frames or buttons. A screen GUI is just what gets the button onto the screen.

Let’s say I put ScreenGui into StarterGui and put a frame inside it called frame. Set the frames visibility to false.

Then I put a part in workspace called part.

You can put this in a local script inside starterGui, characterscripts or playerscripts.

local player = game.Players.LocalPlayer
local part = game.Workspace.part

part.Touched:Connect(function(hit) 
     player.PlayerGui.ScreenGui.frame.Visible = true

end)

Or you could put it in a script (not a localscript)inside the part:

local part = script.Parent

part.Touched:Connect(function(hit) 
     local player = GetPlayerFromCharacter(hit.Parent)
     player.PlayerGui.ScreenGui.frame.Visible = true
end)

6 comments

0

Can you make like gamepass in that?

0

You also could set the ScreenGui.Enabled to false and then set it to true in the function instead of saying.Visible

0

Yes that does not look bad but i would check if its actually a player who is touching

0

Thanks seth for all your help!!!

0

local Part = script.Parent Part.Touched:Connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local player = game.Players:GetPlayerFromCharacter(HIT.Parent) if player then end end end)

0

I have also accepted your answer!!! I would up-vote if I had 25+ Reputation!!!

local player = game.Players.LocalPlayer
	local part = game.Workspace.part
	 part.Touched:Connect(function(hit)
	     player.PlayerGui.ScreenGui.frame.Visible = true
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.