So I want the GI to appear when they die; but I fear that when they do, after a few seconds the gui will go away. Unless there is a way to disable the ability to respawn.
wait(1) text = game.StarterGui.DeathGUI.Frame.NumberCount gui = game.StarterGui.DeathGUI.Frame local b = game.Workspace.Player:FindFirstChild("Humanoid") if b ~= nil then if b.Health == 0 then wait(5) gui.Visible = true end end character:Humanoid.Died:connect(function() local b = game.Workspace.Player:FindFirstChild("Humanoid") if b ~= nil then if b.Health == 0 then wait(5) gui.Visible = true end end end)
(Note: I feel like I posted a question about this a while back, but I cannot find it. Sorry if it is spam.)
Well, i'm not very good with GUI. So your GUI looks fine and all, but there are a few things that need fixing. I'll try not to touch most of your variables and functions, sorry if I do. Here are the following problems with your script:
1) You cant index the player using game.Workspace.Player
because player is not a valid member of the workspace
1a) To fix problem 1 you'd replace it with the following code game.Players.LocalPlayer
. Now this should only work if you place the script in the StarterGui service.
2) With line 14 you cant include two functions/connection lines within that function.
2a) To fix this, you'd have to create a variable at the begging of the script that specifies the player (It would look like this: player = game.Players.LocalPlayer
So now that we have indentified all the problems, let's see what the script would look like:
wait(1) text = game.StarterGui.DeathGUI.Frame.NumberCount gui = game.StarterGui.DeathGUI.Frame player = game.Players.LocalPlayer --We'll create a variable that specifies the client (the player that is running the GUI) local b = player:FindFirstChild("Humanoid") if b ~= nil then if b.Health == 0 then wait(5) gui.Visible = true end end player.Died:connect(function() --now that we've indexed the player, the event were using is a member of that player local b = player:FindFirstChild("Humanoid") if b ~= nil then if b.Health == 0 then wait(5) gui.Visible = true end end end)
Of coarse there may be other stuff that isnt working. I only give the errors that are obvisous and need fixing. If you need a deeper explanation, I have a bunch of links below. If you need help, please comment.
The Players
Service: http://wiki.roblox.com/index.php?title=API:Class/Players
Player
Description: http://wiki.roblox.com/index.php?title=API:Class/Player
An in-depth scripting guide: http://wiki.roblox.com/index.php?title=Scripting_Book