How can I make a GUI appear once you step on a button? It's for one of my morphs.
1.step on brick 2.see if it's a character 3.find character 4.get player from character 5.check if player already has gui 6.if no then give gui.
01 | local gui = script.Gui |
02 |
03 | function OnTouch(hit) |
04 | local human = hit.Parent:findFirstChild( "Humanoid" ) |
05 | if human ~ = nil then |
06 | local char = human.Parent |
07 | local player = game.Players:GetPlayerFromCharacter(char) |
08 | if player ~ = nil then |
09 | local already = player.PlayerGui:findFirstChild(gui.Name) |
10 | if already = = nil then -- makes sure that it doesn't two gui clones. |
11 | local newgui = gui:clone() |
12 | gui.Parent = player.PlayerGui |
13 | end |
14 | end |
15 | end |
16 | end |
17 |
18 | script.Parent.Touched:connect(OnTouch) |