died function won't work for me its a local script in a screengui trying to get a textlabel's text to change to the player's current lives (player has 20 lives total) i tried using a number value but i dont know much about those so im trying this EDIT: got script 1 to work now im trying a way but ill put both local scripts below
script 1 (Edited)
local lives = script.Parent.Lives.CurrentLives.Value
local textlabel = script.Parent.Lives
function onDeath()
print('Someone has died! :0')
lives = (lives - 1)
print(lives)
textlabel.Text = "x"..lives
wait(0)
end
if textlabel.Text == "x0" then do
print("Someone has lost all their lives!")
wait(2)
textlabel.Text = ("GAME OVER!")
script.Parent.Frame.Visible = true
end
end
game.Players.LocalPlayer.Character.Humanoid.Died:connect(onDeath)
script 2 (new)
game.Players.PlayerAdded:connect(function(Player)
local numbvalue = Instance.new('NumberValue')
numbvalue.Parent = Player
numbvalue.Name = 'Lives'
numbvalue.Value = 20
Player.CharacterAdded:connect(function(Character)
Player.PlayerGui.LivesGui.LivesRemaining.Text = 'x'..numbvalue.Value
Character.Humanoid.Died:connect(function()
numbvalue.Value = (numbvalue.Value - 1)
Player.PlayerGui.LivesGui.LivesRemaining.Text = 'x'..numbvalue.Value
print(Player.Name..' has lost a life and now has '..numbvalue.Value..' left!')
end)
end)
end)
help :(

4 comments
Died function wont work
What does the output say?...
Because it works for me
Output says nothing