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???
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???
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)
Can you make like gamepass in that?
You also could set the ScreenGui.Enabled to false and then set it to true in the function instead of saying.Visible
Yes that does not look bad but i would check if its actually a player who is touching
Thanks seth for all your help!!!
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)
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.
2 comments
No, when you touch it with your character.
Yes