✓ Accepted answer
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:
- 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.
- 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
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()
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
5 comments
Mk. I also have this problem 22:12:03.455 - Died is not a valid member of Player 22:12:03.461 - Script 'Players.Player.PlayerGui.DeathGUI.Frame.NumberCount.Script', Line 14 22:12:03.463 - Stack End
Wooops I almost forgot. There is no died event for a certain player. You'd instead replace it with the following code: player.Character.Humanoid.Died:connect(function()
Ok. thanks, now I just need to figure out a way to make it actually appear. By any chance you know how?
I'd be happy to change up the script a little to make it work!
Sure!