Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My game script is having intermission issues?

Asked by 9 years ago

Hi my game script has a few bugs. One bug is that well it repeats Intermission every second of the game it never turns off. Can you help?

while true do
print("Intermission")
game.ReplicatedStorage.Cows:Clone().Parent = workspace
wait(1)
print("Game running")
for _, player in next, game.Players:GetPlayers() do
if getScore(player, "Cow Clicks") >= highScore then
    print("Game over")
    local spawns = {workspace.Part1.Position,workspace.Part2.Position,workspace.Part3.Position}
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
      player.Character:MoveTo(spawns[i]) 
      player.leaderstats["Cow Clicks"].Value = 0
end
end
end
end
end

1 answer

Log in to vote
1
Answered by
Kurieita 125
9 years ago

Well, let break this down.

First you print, then you loop through all the players, then you use a conditional statement and print once again. After that you spawns all the players. And correct me if I am wrong but it does all that with 3 seconds, non stop. Right?

Well to fix this issue you need to do something to 'wait'

Either -Add a game mode of some type -Use a timer or count down -Add a wait

The first two work pretty much in sync together. When I say a game mode of some type I really mean a function

local function GameMode1()
wait(300) --> the round is 300 seconds long
--[[ Do other stuff ]]--
end

A timer would be something like this

local Time = 300 --Round time is 300 seconds long and print every second

while Time > 1 do 
print(Time)
wait(1)
end

The last is just a simple 'wait'

wait(300)

In fact, I am pretty sure all three use a yield function, aka 'wait'

To sum it up, your main problem was there you was not doing any type of waiting between the intermission and game running.

Remember these are just three of the many solution to the problem. You could always make a if statement that represent something aka a variable 'GameOn'

Ad

Answer this question