I tried that, and it doesn’t change anything, could you help me?
Instead, I tried this but it didn’t work:
''''
game.ReplicatedStorage.WhichGamemode.OnInvoke = (function(chosen)
-- stuff I don't want to leak
end
while true do
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 30,1,-1 do
text.Value = "Intermission "..i
wait(1)
if i == 1 then
print("Picking gamemode")
end
end
end
'''
No errors
Why do you use a seperate event to choose a gamemode? Choose the gamemode from your original script instead. Also, if you’re literally just connecting the event after 20 seconds, and the event fires EVEN A MILISECOND faster, you won’t be getting a result.
That still doesn’t solve my problem
You don’t have to check constantly if i == 1, just do it like this:
for i = 30,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
print("Picking gamemode")
Also, use WaitForChild()
in case the Script checks too fast if an item is somewhere without it loading first, because it will terminate the entire thread if that happens.
Moving on, I see that you are containing this in a while true do wait() end
loop, meaning as soon as the Script prints out “Picking gamemode”, it’ll finish it’s current thread and restart the countdown, because it’s in a loop.
Ok it is better, but it is doing the intermission part while it is doing the game part, even though only the game part should be showing. (Also, where is the WaitForChild() in my script?)
e.g. use game.ReplicatedStorage:WaitForChild("ShowVotes")
instead of game.ReplicatedStorage.ShowVotes
For your other issue, if you’re completely done with while true do wait() end
and want to move on with the rest of the script, put break
right above the end
that’s for while true do
.
If you want to know why break
didn’t work previously, it’s because you didn’t end while true do wait() end
, you ended the for i = 10, 0, -1 do wait(1) end
loop, which caused it to restart the countdown.
Oh the updated script is this:
Here’s how it should be:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WhichGamemode = ReplicatedStorage:WaitForChild("WhichGamemode", 5)
local ShowVotes = ReplicatedStorage:WaitForChild("ShowVotes", 5)
local Sound1 = workspace:WaitForChild("Sound1", 5)
WhichGamemode.OnInvoke = function(chosen) --You had an extra "(" here, this was the reason your script didn't run.
--stuff you don't want to leak
end
while true do
ShowVotes:FireAllClients()
Sound1:Play()
for i = 30, 1, -1 do
text.Value = "Intermission "..i
wait(1)
end
print("Picking gamemode")
wait()
break --End the loop so that the script can continue on from this point, although you should just remove while true do wait() end altogether.
end
Trust me, being organized pays off.
Ok it doesn’t loop at the wrong spot anymore, but the whole code doesn’t loop again when the round is over
Oh. Now I see what your point is. Basically, after specifying all variables and functions, put a while true do wait() end
loop and then end it at the last line of the script, pretty much.
Like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WhichGamemode = ReplicatedStorage:WaitForChild("WhichGamemode", 5)
local ShowVotes = ReplicatedStorage:WaitForChild("ShowVotes", 5)
local Sound1 = workspace:WaitForChild("Sound1", 5)
--Do not include variables or functions! (e.g. while true do local function lol() end wait() end)
while true do
WhichGamemode.OnInvoke = function(chosen) --You had an extra "(" here, this was the reason your script didn't run.
--stuff you don't want to leak
end
ShowVotes:FireAllClients()
Sound1:Play()
for i = 30, 1, -1 do
text.Value = "Intermission "..i
wait(1)
end
print("Picking gamemode")
wait()
--put everything else here in the script that's under this part
end
Then it just loops at the wrong place again, the script above your most recent script works but stops working after the round is over