Ad
Log in to vote
0

How can I fix this intermission script that breaks when another player touches it?

Asked by 25 days ago

It works perfectly for one player but when another player touches it, it pauses the first player's gui timer.

ready_players = {}
local timer = script.Timer
local debounce = false
local rs = game:GetService("ReplicatedStorage")
local Countdown:BoolValue = script.Bool

rs.TeleportTouched.OnServerEvent:Connect(function(Player,hit,char,gui,playergui)
    timergui = gui:WaitForChild("Timer")
    if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
        if not table.find(ready_players,Player.Name) then
            table.insert(ready_players,Player)
            print("in")
        debounce = true
        task.wait(1)
            hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = game.Workspace.waitingRoom.CFrame
            print(ready_players)
            if Countdown.Value == false then
                Countdown.Value = true
                print("counting down")
                end
        end
    end
end)

function startGame()
    print("starting")
end

Countdown:GetPropertyChangedSignal("Value"):Connect(function()
    wait(4) 
    while true do
        task.wait(1)
            print(timer)
            timer.Value = timer.Value - 1
        timergui.Text = tostring(timer.Value)
        if timer.Value == 0 then
            startGame()
            ---restart timer (w.i.p)
            task.wait(0.1)
                timer.Value = 26
            end
        end
    end)

screenshot example: i.imgur.com/yJ3JbN1.png the local script is just an ontouch with localplayer with some effects timer is just an IntValue.

thanks :)

Answer this question