jonjon55
|
  |
| Joined: 24 Oct 2009 |
| Total Posts: 78 |
|
|
| 29 Dec 2013 04:45 PM |
Hello, I have a question about GUI's. Sometimes when I create gui's for a game introduction it displays the gui to my character and it works fine, but why is it when I die it re-shows the gui again. Is there a way I could make that stop? I might sound stupid for asking this. but your knowledge would help :)
- thanks |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:52 PM |
I know why, its hard to put into words. Someone will correct me I know it.
Anyways, so when ever the Character Spawns again, it resets the GUI. Does the same if you were to leave too. I'm not sure if I know how to prevent this, but I think you may have to make it nil after it's been shown, or try using :Destroy() instead of :remove(). I believe :Destroy() works. I was told remove makes it still in workspace, but not present to the player(s) and Destroy removes it from the game.
"Don't walk behind me, I may not lead. Don't walk in front of me, I may not follow. Just walk beside me and be my friend." |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:55 PM |
The best way to do this is to use the CharacterAdded event, along with the PlayerAdded event to only show the GUI once (when they first enter the game). If you put the GUI inside StarterGui, it will show every time the player spawns.
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:wait() GUI:Clone().Parent = p.PlayerGui end) |
|
|
| Report Abuse |
|
|
jonjon55
|
  |
| Joined: 24 Oct 2009 |
| Total Posts: 78 |
|
|
| 29 Dec 2013 04:57 PM |
| Yeah, Thanks guys:) that's all I need |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:58 PM |
at the end of the into gui..
frame = script.Parent Gui = frame.Parent Gui:Destroy() |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:58 PM |
You're kind of right. When a player's character dies their playergui is cleared. The reason it is showing up after they spawn is because you put it in startergui.
Everything in startergui is cloned into every players playergui every time they spawn.
Destroy. Will remove an item and LOCK its parent. Remove will remove an item and not lock its parent
So: H:Destroy() H.Parent = Workspace --Error
H:Remove() H.Parent = Workspace -- is fine
In order for it to only show up once you have to use a script:
----------------------------------------------------------------------------
--Put Intro Guis inside this script
function Give(Player) for _,n in pairs(script:GetChildren()) do n:Clone().Parent = Player.PlayerGui end end Game.Players.PlayerAdded:connect(Give) for _,n in pairs(Game.Players:GetPlayers()) do Give(n) end |
|
|
| Report Abuse |
|
|