|
| 09 Jan 2013 08:08 PM |
So I've got this GUI Giver thingy that gives you the GUI into your PlayerGui when you touch it. It's supposed to give it to you when you touch the brick, then take it away when you leave the brick. It does that just fine, but if you try to get the GUI again, it gives you a "Disconnected event because of exception" message in Output. Here's the script:
local Gui = script.AlarmBroadcastGui local c = Gui:Clone() script.Parent.Touched:connect(function(hit) local char = hit.Parent local player = game.Players:GetPlayerFromCharacter(char) c.Parent = player.PlayerGui end) script.Parent.TouchEnded:connect(function(hit2) local char2 = hit2.Parent local player2 = game.Players:GetPlayerFromCharacter(char2) local Gui2 = player2.PlayerGui:FindFirstChild("AlarmBroadcastGui") if Gui2 ~= nil then Gui2:Destroy() end end) |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 09 Jan 2013 08:14 PM |
local Gui = script.AlarmBroadcastGui script.Parent.Touched:connect(function(hit) human = hit.Parent:findFirstChild("Humanoid") if human then player = game.Players:GetPlayerFromCharacter(hit.Parent) local c = Gui:Clone() c.Parent = player.PlayerGui elseif not human then c:Destroy() end end) |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 09 Jan 2013 08:16 PM |
| i no like using da touchended :x |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2013 08:28 PM |
| Problem though. It needs to remove the GUI when the brick is left. It's also in a thing to get weapons from a GUI. Except the Weapon GUI is this big thing in the middle of the screen. If it were just the alarm system it'd be fine. Thanks anyways. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2013 08:32 PM |
local Gui = script.AlarmBroadcastGui script.Parent.Touched:connect(function(hit) local char = hit.Parent local player = game.Players:GetPlayerFromCharacter(char) if not char or player then return end local c = Gui:Clone() c.Parent = player.PlayerGui end) script.Parent.TouchEnded:connect(function(hit2) local char2 = hit2.Parent local player2 = game.Players:GetPlayerFromCharacter(char2) local Gui2 = player2.PlayerGui:FindFirstChild("AlarmBroadcastGui") if Gui2 ~= nil then Gui2:Destroy() end end)
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2013 08:32 PM |
Change:
if not char or player then return end
to:
if not char or not player then return end
¤ ¤ † K M X D † ¤ ¤
|
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
| |
|