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

This script's broken, what's wrong with it? This is what it does.

Asked by
Irvene 5
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

This script is broken, it's a gamescript it's supposed to wait for 2 players, if there's not then it creates an infinate loop warning the player, until there's 2 or more, then it's supposed to create 2 teams, then team them all evenly and respawn them all, because the map will be selected. then it waits 250 seconds, and it starts over again once all players on 1 team are eliminated then they should all be in spectators.

repeat wait(0)until game:FindFirstChild("Teams")
local NumPlayers = 2 --Change this to the number of players needed
local GameTime = 250 --5 minutes
local A = game.Players
local A1 = "This service is unavailable, please wait until 1 more player joins..."
local A2 = "Welcome to the official meadows sfing game"
local A4 = "5"
local A3 = "The amount of players is successful, and the game will be starting in" .. A4 .. "Seconds.."
local A5 = "Teaming players..."
local A6 = "Blue team has won"
local A7 = "Red team has won"
local BlueTeam = game.Teams:WaitForChild("BlueTeam"):Clone()
local RedTeam = game.Teams:WaitForChild("RedTeam"):Clone()
local redplayers = 0
local blueplayers = 0
local M = Instance.new("Message",game.Workspace)
local H = Instance.new("Hint",game.Workspace)
local TimeForLoop = .5 --This will loop the script every .5 seconds
local players = 0
local GameRun = false
local GameOver = false
local RegenTeams = false

function fixTeams()
local Blue = BlueTeam:Clone()
Blue.Parent = game.Teams
local Red = RedTeam:Clone()
Red.Parent = game.Teams 
end

function checkSpectators()
spectators = 0
for _, player in pairs(game.Players:GetChildren()) do
if player.TeamColor == game.Teams.Spectators.TeamColor then
spectators = spectators + 1
if(spectators >= NumPlayers) then
BlueTeam:remove()
RedTeam:remove()
wait(3)
end
end
end
end

function findwinner()
if GameOver then
for _, player in pairs(game.Players:GetPlayers()) do
if player.TeamColor == BlueTeam.TeamColor then
players = blueplayers + 1
wait(5)
if blueplayers == 0 then
print("Blue team has lost")
M.Text = A7
elseif player.TeamColor == RedTeam.TeamColor then
players = redplayers + 1
if redplayers == 0 then
print("Red team has lost")
M.Text = A6
end
end
end
end
end
end

function RegenPlrs()
for i,v in pairs(game.Players:GetPlayers())do
if v and v.Character then
v.Character:BreakJoints()
end
end
end

function StartGame()
if GameRun then
fixteams()
RegenPlrs()
checkspectators()
findwinner()
end
end

coroutine.resume(coroutine.create(function()
while wait(TimeForLoop)do
if not #A:GetPlayers() >= NumPlayers then
M.Text = A1
else
StartGame()
M.Text = ""
wait(1)
M.Text = A2
wait(5)
M.Text = A3
for z = 5, 0, -1 do
M.Text = ""..z
wait(1)
end
for i = GameTime, 0, -1 do
H.Text = "Time left: "..i
wait(1)
end
wait(2)
M.Text = "Times up!"
wait(2)
M.Text = "Starting new round..."
wait(2.5)
end
end
end))

2 answers

Log in to vote
1
Answered by 9 years ago

Stop reposting the same question.

Ad
Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

I hate to see you repost this question again and again, and I don't see what could be wrong.

  • The script should be in Workspace or ServerScriptService (make sure it's not in ServerStorage, I stupididly did that when testing my AntiCurse script)

  • It should not be disabled.

  • It is not giving you errors in server console (also make sure you're not only looking at local console).

Try printing through several areas of the code, like enough players in game and coroutine/loop started. See where those prints stop and edit this post, I will favorite this question and see if you edit it later.

Please refrain from reposting this question.


I kind of wish that there was like a daily bump button, your question hasn't been bumped in a day, you can bring it back to the top question.

Answer this question