Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How can I make this timer reset when a BoolValue is false and recount when true again?

Asked by
pwnd64 106
9 years ago

So so sorry to post again so soon (I feel like a leech :( ) but the code so generously fixed for me by Goulstem (Shoutout!) fixes all of my problems except for one -

I'm trying to make this code stop running the timer when a value is made false by one team touching it and restart the timer when the value is made true again by another team touching it.

local timer = 1
local totaltimer = 1
local ValueA = game.Workspace.PartA.ValueA
local ValueB = game.Workspace.PartB.ValueB
local ValueC = game.Workspace.PartC.ValueC

repeat wait() until ValueA.Value and ValueB.Value and ValueC.Value
repeat print'cool' wait(1) timer = timer + 1 until timer > 5 or ValueA.Value==false or ValueB.Value==false or ValueC.Value==false

timer= totaltimer

game.Lighting.RaidersWin:Clone().Parent = game.Players.LocalPlayer.PlayerGui

for i, player in ipairs(game.Players:GetPlayers()) do
    if player.Character then
        local hum = player.Character:FindFirstChild('Humanoid')
        if hum then
            hum.Health = 0
            timer=totaltimer
            ValueA.Value=false
            ValueB.Value=false
            ValueC.Value=false
            workspace.PartA.BrickColor=BrickColor.new"Earth green"
            workspace.PartB.BrickColor=BrickColor.new"Earth green"
            workspace.PartC.BrickColor=BrickColor.new"Earth green"
        end
    end
end

I have tried using

local timer = 1
local totaltimer = 1
local ValueA = game.Workspace.PartA.ValueA
local ValueB = game.Workspace.PartB.ValueB
local ValueC = game.Workspace.PartC.ValueC

repeat wait() until ValueA.Value and ValueB.Value and ValueC.Value
repeat print'cool' wait(1) timer = timer + 1 until timer > 5

timer= totaltimer

game.Lighting.RaidersWin:Clone().Parent = game.Players.LocalPlayer.PlayerGui

for i, player in ipairs(game.Players:GetPlayers()) do
    if player.Character then
        local hum = player.Character:FindFirstChild('Humanoid')
        if hum then
            hum.Health = 0
            timer=totaltimer
            ValueA.Value=false
            ValueB.Value=false
            ValueC.Value=false
            workspace.PartA.BrickColor=BrickColor.new"Earth green"
            workspace.PartB.BrickColor=BrickColor.new"Earth green"
            workspace.PartC.BrickColor=BrickColor.new"Earth green"
        end
    end

but it doesnt seem to work, sorry for posting another question so soon and thanks for reading!

2
You should show your attempts. NotsoPenguin 705 — 9y
0
Edited, sorry pwnd64 106 — 9y

Answer this question