#countdown for 2 player pairing
1 messages · Page 1 of 1 (latest)
--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)```
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
ill letr you know im a dumbass first and foremost BUT i can atleast try to help
--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
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
wanna go to a call so i can screenshare
not rn sadly i cant
why
maybe later hold on
everything worked well now
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
what
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
i dont understand
like it would reset due to the player sending the fireserver event
but i feel like im gonna pass out if i get more info
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
ur stupid
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
can i post this in #📜︱scripting
wth im trying to help