#countdown for 2 player pairing

1 messages · Page 1 of 1 (latest)

cerulean cape
#

it bugs in very specific scenarios

#
--code variables
local running = true
local currentTime = 50 --5 * 10

leaveButton.MouseButton1Click:Connect(function()
    running = false
end)

countdownRemote.OnClientEvent:Connect(function(setName, houseName)
    
    local set: Folder = houses:FindFirstChild(setName)
    local otherHouse: Model = set:FindFirstChild(houseName).Name == "cowboy" and set.horse or set.cowboy
    local otherInHouse: StringValue = otherHouse:WaitForChild("PlayerInHouse")
    
    local tween = TweenService:Create(timer, tweenInfo, {BackgroundTransparency = 0, TextTransparency = 0})
    tween:Play()
    tween.Completed:Wait()
    
    while true do
        if not running or otherInHouse.Value == ""  then
            running = true
            break
        else
            currentTime -= 1
            timer.Text = tostring(currentTime / 10)
                
            if currentTime <= 0 then
                if houseName == "cowboy" then countdownRemote:FireServer(setName, houseName) end
                
                running = true
                break
            end
                
            task.wait(0.1)
        end
    end
    
    local tween = TweenService:Create(timer, tweenInfo, {BackgroundTransparency = 1, TextTransparency = 1})
    tween:Play()
    tween.Completed:Wait()

    currentTime = 50 --5 * 10
    timer.Text = "5"
end)```
sharp gull
#

any errors in output

#

or nothing?

cerulean cape
#

no errors

#

just doesnt work as intended

#

one of the cases are when you complete the countdown, theres a chance that you (or the other player)'s gui will completely break

#

structure

sharp gull
#

ill letr you know im a dumbass first and foremost BUT i can atleast try to help

cerulean cape
#

ok

#

❤️

sharp gull
#
--code variables
local running = true
local currentTime = 50 --5 * 10

leaveButton.MouseButton1Click:Connect(function()
    running = false
end)

countdownRemote.OnClientEvent:Connect(function(setName, houseName)
    
    local set: Folder = houses:FindFirstChild(setName)
    local otherHouse: Model = set:FindFirstChild(houseName).Name == "cowboy" and set.horse or set.cowboy
    local otherInHouse: StringValue = otherHouse:WaitForChild("PlayerInHouse")
    
    local tween = TweenService:Create(timer, tweenInfo, {BackgroundTransparency = 0, TextTransparency = 0})
    tween:Play()
    tween.Completed:Wait()
    
    while true do
        if not running or otherInHouse.Value == ""  then
            print("test not running") --add these
            running = true
            break
        else
            print("test running") --add these
            currentTime -= 1
            timer.Text = tostring(currentTime / 10)
                
            if currentTime <= 0 then
                if houseName == "cowboy" then countdownRemote:FireServer(setName, houseName) end
                
                running = true
                break
            end
                
            task.wait(0.1)
        end
    end
    
    local tween = TweenService:Create(timer, tweenInfo, {BackgroundTransparency = 1, TextTransparency = 1})
    tween:Play()
    tween.Completed:Wait()

    currentTime = 50 --5 * 10
    timer.Text = "5"
end)
#

look for my comments --add these

#

under while true do

cerulean cape
#

the countdown works

#

its just that

#

fine

sharp gull
#

look i obviously dont have access to ur game so im just guessing add the print statements everywhere

#

test if any of them dont run properly\

#

add them where ever you think its breaking

#

it will narrow down the problem

cerulean cape
#

wanna go to a call so i can screenshare

sharp gull
#

not rn sadly i cant

cerulean cape
#

why

sharp gull
#

maybe later hold on

cerulean cape
#

everything worked well now

sharp gull
#

nice

#

what chaNGED

cerulean cape
#

nothing

#

i don know why it sometimes works sometimes doesnt

sharp gull
#

IT MIght have something to do with calling the server on 2 different accounts you might need to refer to each player by their userid

cerulean cape
#

what

sharp gull
#

this was an issue i had with a crate game i made where if 2 players spun it at once it would run the countdown wrong between each player

cerulean cape
#

i dont understand

sharp gull
#

like it would reset due to the player sending the fireserver event

cerulean cape
#

but i feel like im gonna pass out if i get more info

sharp gull
#

the server doesnt differienciate between players.. so if the client fires server even when you put the 'player' into its arguments sometimes it will fire for both players anyway

#

its stupid

cerulean cape
#

ur stupid

sharp gull
#

so you have to set something like a countdown seperate for each player

#

i dont know your game and i cant call rn so ofc im might be getting this wrong

#

for your particular issue

cerulean cape
sharp gull
#

wth im trying to help

cerulean cape
#

yes?

#

thank you