hi, i made a screengui and put it in startergui, so now i need to have the text in the gui change when the player dies. the text starts as 25 so when the player dies i need the text to change to 24 and then when they die again it changes to 23 and so on. also when the text reaches 1 it sets their currency (Stage) to 1 and sets the text back to 25.
this is a script i though could be a start (its a child of the Lives gui)
game.Players.LocalPlayer.Humanoid.Health = 0 script.Parent.TextLabel.Text = 24 end game.Players.LocalPlayer.Humanoid.Health = 0 and script.Parent.TextLabel.Text = 24 then do script.Parent.TextLabel.Text = 23
There’s an event on the humanoid called Died
. It runs every time the player dies. You can use that so the text changes every time the player dies.
Here’s a link to it if you want to learn more about it :
http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died
I’d make an example script but I can’t because I’m on mobile.
Disable the "ResetOnSpawn" value that is in the "ScreenGUI" properties.
Then you can do this:
local Player = game.Players.LocalPlayer local Number = 25 function Update() local StringNumber = tostring(Number) script.Parent.TextLabel.Text = StringNumber end Player.CharacterAdded:connect(function(Character) Character:WaitForChild("Humanoid").Died:connect(function() if Number < 2 then Number = 25 Update() else Number = Number -1 Update() end end) end)
You could use the humanoid.Died function. I'll give an example here:
game.Players.LocalPlayer.Character.humanoid.Died:connect(function() --YOUR GUI SCRIPT HERE end)
When the player dies, the script in the block will run.