So I’m using code from my other thread: Intermission Restarting For Some Reason The problem is, that I want the loop to break but when a new round starts to make it loop again. (The reason my code looks like that is because before my code used to loop at the wrong line, but this code fixes that problem)
while true do
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
wait()
break
end
its less an issue of code, and more an issue of logic.
You just need to call a function when the round ends, not an infinite loop.
While loops are useful for information that you’d want constantly updating, but in this senario, it’d be better to simply set up a series of functions that can wait an indefinite amount of time until called into action.
''''
local function Intermission()
while true do
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
wait()
break
end
end
Intermission()
'''
// Game round script has ended and called Intermission()
local function Intermission()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end // Call next module, in this case your ByeVotes area
end
local function LaunchNextRound()
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
*instert game mode selection code here*
end
local function Gamemode1()
*insert game mode code here*
Call Intermission()
this is heavy on the psudo code, but its an example of the logical structure I would suggest.
''''
local function Intermission()
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
end
Intermission()
local function Choose()
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
end
Choose()
'''
But I still don’t understand how you can call a function even if the script doesn’t know what the function is
You’ll have to set up the code so the preceding function calls the next; Ie
intermission()
calls Choose()
and then Choose() calls your game mode
and then Gamemode() calls your EndGame/Intermission.
function MyFunction()
while true do
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
wait()
break
end
end
''''
local function Pick()
game.ReplicatedStorage.ByeVotes:FireAllClients()
print("Picking gamemode")
wait()
Gamemode()
end
function Intermission()
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
Pick()
end
'''
Ok now in in the same script, it won’t print “yay”
''''
function Intermission()
wait()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
print("Yay")
game.ReplicatedStorage.Function:Fire()
print("yay2")
end
'''