Hello, I want to make it so that when the player runs out of steps, they die. I’ve got that part working but when they die, the steps counter resets back to the default 100 even though the stage sets it to be 25. How would I make it so that the steps is 25 and when they die its also 25, but also make it so that it works for any stage.
Heres an example of what I want: Player begins stage 1. Steps counter is 100. They run out and die, their step counter resets back to 100. Player begins stage 2. Step counter is 25 they run out and die. Their step counter is 25 when they respawn.
Heres an example of what’s happening right now: Player begins stage 1. Steps counter is 100. They run out and die, their step counter resets back to 100. Player begins stage 2. Step counter is 25 they run out and die. Their step counter is back to 100 when they respawn.
Here is my current code:
local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild("Humanoid")
local steps = player.PlayerGui.StepsGUI.Frame.TextLabel
local stagetrans = player.PlayerGui.StageTransfer.CurrentStage
print(steps.Text)
stagetrans:GetPropertyChangedSignal("Text"):Connect(function()
if stagetrans.Text == "0" then
steps.Text = "9999999"
elseif stagetrans.Text == "1" then
steps.Text = "100"
elseif stagetrans.Text == "2" then
steps.Text = "75"
elseif stagetrans.Text == "3" then
steps.Text = "125"
elseif stagetrans.Text == "4" then
steps.Text = "25"
end
end)
while task.wait(.1) do
if Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
local new = tonumber(steps.Text)-1
local text = tostring(new)
player.PlayerGui.StepsGUI.Frame.TextLabel.Text = text
if new == 0 then
Humanoid.Health -=100
break
elseif new <= 15 then
steps.TextColor3 = Color3.new(0.866667, 0, 0.0156863)
steps.Parent.ImageLabel.ImageColor3 = Color3.new(0.866667, 0, 0.0156863)
elseif new >= 16 then
steps.TextColor3 = Color3.new(255,255,255)
steps.Parent.ImageLabel.ImageColor3 = Color3.new(255,255,255)
end
end
end