#stagelabel isn't working as intended

1 messages · Page 1 of 1 (latest)

analog flume
#

this script I made is supposed to change the ''StageLabel'' Text Label to whatever stage the player is in , if the player dies (for example in stage two) the label goes back to'' Stage One'' instead of ''Stage Two'' and its not supposed to happen, how do i fix this? (there is also a timer, but the timer works as intended)

''local StageGui = script.Parent
local StageLabel = StageGui.StageLabel
local TimerLabel = StageGui.TimerLabel
local InStage = false

local Player = game.Players.LocalPlayer

wait(2)

local stages = {
game.Workspace.StageOne,
game.Workspace.StageTwo,
game.Workspace.StageThree

}

local function StartTimer()
local minutes = 0
local seconds = 0

repeat 
    seconds = seconds + 1
    
    if seconds == 60 then
        minutes = minutes + 1
        seconds = 0
    end
    
    if minutes > 9 and seconds > 9 then
        TimerLabel.Text = minutes .. ":" .. seconds    
    elseif minutes > 9 then
        TimerLabel.Text = minutes .. ":0" .. seconds
    elseif seconds > 9 then
        TimerLabel.Text = "0".. minutes .. ":" .. seconds    
    else
        TimerLabel.Text = "0".. minutes .. ":0" .. seconds
    end
    
    wait(1)
until not InStage

end

local function EndTimer()
InStage = false
TimerLabel.Text = "00:00"

end
for i, stage in pairs(stages) do

stage.Start.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        StageLabel.Text = stage.Start.StageName.Value
         
         InStage = true
         
         StartTimer()
    end
end)

end

for i, stage in pairs(stages) do

stage.End.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
         EndTimer()
        InStage = false
    end
end)

end

nimble harness
#

are u finding humanoid in workspace..

analog flume
#

that's a mistake i already removed it

#

idk why i did that..

nimble harness
#

You can store the current stage and only update when it’s different.
Dont reset InStage = false at the last 4 line

#

U can try to script a code so it remembers the player stage after death so it doesnt reset u to stage 1 if youre at stage 2

proper berry
proper berry