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

This script should start timer countdown but there is a problem?

Asked by 4 years ago
Edited 4 years ago

it only works in one players and the intermission label doesnt become visible

local re = game.ReplicatedStorage
local rev = game.ReplicatedStorage.RemoteEvent3
local rev2 = game.ReplicatedStorage.RemoteEvent4
local timer = re.timer
local rev3 = re.RemoteEvent5

local plrn = #game.Players:GetPlayers()

while true do
    local NotEnoughPlayers = game.ReplicatedStorage.bool
    local Enoughplayers = false
    local timeractive = false

    if plrn < 2 then
        NotEnoughPlayers.Value = true
    end
    while NotEnoughPlayers.Value == true do
        wait(3)
        rev:FireAllClients()
    end
    if plrn >= 2 then
        timeractive = true
        NotEnoughPlayers.Value = false
    end
    while timeractive do
        wait(1)
        timer.Value = timer.Value - 1
        rev2:FireAllClients()
        rev3:FireAllClients()
    end
end

in intermission label local script :

local rev3 = game.ReplicatedStorage.RemoteEvent5
local timer = game.ReplicatedStorage.timer

rev3.OnClientEvent:Connect(function()
    timer.Changed:Connect(function()
        script.Parent.Text = "Intermission:".. timer.Value
        script.Parent.Visible = true
    end)
end)

in "there is not enough players label" localscript

local rep = game:GetService("ReplicatedStorage")
local re = game.ReplicatedStorage.RemoteEvent3
local re2 = game.ReplicatedStorage.RemoteEvent4
local plrn = #game.Players:GetPlayers()

local function oncev()
    if plrn < 2 then
        script.Parent.Visible = true
    end
end

local function oncev2()
    script.Parent.Visible = false
end

re.OnClientEvent:Connect(oncev)
re2.OnClientEvent:Connect(oncev2)


Answer this question