Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how can i change text in a gui when the player dies?

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

3 answers

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)

3 comments

0

it works, but how can i make it so it sets the players Stage value to 1?

0

What do you mean?

0

so when the number reaches 1, it sets all currencies to their original value, also it only works in studio

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.