#i need someone to help me add or just completely remake this code. any helpers?

13 messages · Page 1 of 1 (latest)

harsh dawn
#

i need a part of this code to make it so when the player resets/dies, the timer doesnt reset. it sounds simple to me but there might be more to it that i dont get since im a modeler not a coder. can anyone help please?

local MessagingService = game:GetService("MessagingService")
local CountdownLabel = script.Parent:WaitForChild("Countdown")

local function startCountdown(duration, message)
    for i = duration, 0, -1 do
        CountdownLabel.Text = message .. ": " .. string.format("%02d:%02d", math.floor(i / 60), i % 60)
        wait(1)
    end
end

local function onToySoldiersSpawned()
    startCountdown(10 * 60, "Toy Soldiers will despawn in")
end

local function onToySoldiersDespawned()
    startCountdown(15 * 60, "Toy Soldiers will spawn in")
end

MessagingService:SubscribeAsync("ToySoldiersSpawned", function()
    onToySoldiersSpawned()
end)

MessagingService:SubscribeAsync("ToySoldiersDespawned", function()
    onToySoldiersDespawned()
end)

-- Start initial countdown
startCountdown(15 * 60, "Toy Soldiers will spawn in")
#

please let me know if you need more of the code or like screenshots to the other scripts and such, i can also just provide permission to the game.

little frost
# harsh dawn i need a part of this code to make it so when the player resets/dies, the timer ...

Maybe try smthn like this in the first bit? Lmk if it still resets when the player dies

local MessagingService = game:GetService("MessagingService")
local CountdownLabel = script.Parent:WaitForChild("Countdown")
local TimerStarted = false 

local function startCountdown(duration, message)
    if not TimerStarted then
        TimerStarted = true
        for i = duration, 0, -1 do
            CountdownLabel.Text = message .. ": " .. string.format("%02d:%02d", math.floor(i / 60), i % 60)
            wait(1)
        end
    end
end
harsh dawn
#

still resets the timer 😭

little frost
#

wait I think in the gui and stuff there might be a "reset on spawn" option that may need ticked off

harsh dawn
#

oh sweet thanks

idle galleonBOT
#

studio** You are now Level 1! **studio

harsh dawn
#

fixed it

#

used roblox studio for over 3 years and im still learning new things every day 😭

little frost
#

was it the reset one death thingy

harsh dawn
#

i just unchecked the resetonspawn thing under the screengui