|
| 16 Sep 2012 04:54 AM |
| I'm making a GUI that appears when you step on a certain brick, but I want the GUI to appear only once, but I have no idea how to do that. Can I have some help please?:D |
|
|
| Report Abuse |
|
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 16 Sep 2012 05:12 AM |
Well try this: if the player hits the brick, it first checks for the GUI. If the GUI is already opened the script does nothing. Else the script opens the GUI. If textlabel.Visible == false then textlabel.Visible = true end |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 16 Sep 2012 05:33 AM |
function onTouched() script.Disabled = true --Rest of script goes here |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 01 Oct 2012 04:12 AM |
| you dont have to add a debounce! cause it doesn't matter if the event connects like 2 times at once to the function that makes the gui appear. cause it'll stay visible after touching! |
|
|
| Report Abuse |
|
|
|
| 01 Oct 2012 06:38 AM |
You could do
Connect = .Touched:connect() Connect:disconnect() |
|
|
| Report Abuse |
|
|
|
| 01 Oct 2012 07:40 AM |
sycips is right. Simply check whether the GUI exists - all the other options people have suggested may make the script seem "broken" to other players.
--pseudocode-ish example GUI = script.Parent.DefineThisPls
script.Parent.Touched:connect( function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and plr.PlayerGui then --check if player exists
if not plr.PlayerGui:FindFirstChild(GUI.Name) then --proceed only if GUI isn't copied yet
local g = GUI:Clone() g.Parent = plr.PlayerGui
end
end
end) |
|
|
| Report Abuse |
|
|