Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
goodlead -62
3 years ago
Edited 3 years ago

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???

0
No, when you touch it with your character. goodlead -62 — 3y
0
Yes iivSnooxy 248 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
0
Can you make like gamepass in that? iivSnooxy 248 — 3y
0
You also could set the ScreenGui.Enabled to false and then set it to true in the function instead of saying.Visible SethHeinzman 284 — 3y
0
Yes that does not look bad but i would check if its actually a player who is touching esepek 103 — 3y
0
Thanks seth for all your help!!! goodlead -62 — 3y
View all comments (2 more)
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) esepek 103 — 3y
0
I have also accepted your answer!!! I would up-vote if I had 25+ Reputation!!! goodlead -62 — 3y
Ad
Log in to vote
0
Answered by
iivSnooxy 248 Moderation Voter
3 years ago
local player = game.Players.LocalPlayer
    local part = game.Workspace.part
     part.Touched:Connect(function(hit)
         player.PlayerGui.ScreenGui.frame.Visible = true
end)

Answer this question