-
What do you want to achieve? Keep it simple and clear!
My script doesn’t work after a round -
What is the issue? Include screenshots / videos if possible!
I believe that this part of the script doesn’t work:
for i, v in pairs(game.Players:GetChildren()) do
local Position = game.ServerStorage.PlatePositions:GetChildren()[math.random(1, #game.ServerStorage.PlatePositions:GetChildren())]
Position.Parent = game.ServerStorage.UsedPositions
local Plate = game.ServerStorage.Plate:Clone()
Plate.Name = v.Name
Plate.Parent = workspace.Plates
Plate.Position = Position.Position
v.Character.HumanoidRootPart.CFrame = Plate.CFrame + Vector3.new(0, 5, 0)
v.TeamColor = game.Teams.Playing.TeamColor
end
here’s the full script:
local Timer = 20
local IsIntermission = true
local Players = game:GetService("Players")
local WaitingForMorePlayers = false
-- Functions
function Intermission()
repeat
local PlayerAmount = #Players:GetPlayers()
if PlayerAmount >= 2 then
repeat
Timer -= 1
game.ReplicatedStorage.Announce:FireAllClients("Intermission: " .. Timer)
task.wait(1)
until Timer == 0 or WaitingForMorePlayers == true
else
if 2 - PlayerAmount == 1 then
game.ReplicatedStorage.Announce:FireAllClients("Waiting for " .. 2 - PlayerAmount .. " player...")
WaitingForMorePlayers = true
else
game.ReplicatedStorage.Announce:FireAllClients("Waiting for " .. 2 - PlayerAmount .. " players...")
WaitingForMorePlayers = true
end
end
if Timer == 0 then
IsIntermission = false
end
task.wait()
until IsIntermission == false
end
function PlayRandomEvent()
local Event = script.Events:GetChildren()[math.random(1, #script.Events:GetChildren())]
local PickedPlate = workspace.Plates:GetChildren()[math.random(1, #workspace.Plates:GetChildren())]
game.ReplicatedStorage.Announce:FireAllClients(Event.EventAnnouncement.Value)
task.wait(5)
game.ReplicatedStorage.Announce:FireAllClients(" ")
local Clone = Event:Clone()
Clone:ClearAllChildren()
Clone.Parent = PickedPlate
Clone.Disabled = false
task.wait(1.5)
end
function EndGame()
IsIntermission = true
for i, v in pairs(game.Players:GetChildren()) do
if v.TeamColor == game.Teams.Playing.TeamColor then
v:WaitForChild("leaderstats"):WaitForChild("Wins").Value += 1
v.TeamColor = game.Teams.Lobby.TeamColor
v.Character.Humanoid.Health = 0
game.ReplicatedStorage.Announce:FireAllClients(v.Name .. " wins!")
end
end
workspace.Plates:ClearAllChildren()
for i, v in pairs(game.ServerStorage.UsedPos:GetChildren()) do
v.Parent = game.ServerStorage.PlatePositions
end
wait(5)
Timer = 5
Intermission()
end
-- Game
while wait() do
Intermission()
for i, v in pairs(game.Players:GetChildren()) do
local Position = game.ServerStorage.PlatePositions:GetChildren()[math.random(1, #game.ServerStorage.PlatePositions:GetChildren())]
Position.Parent = game.ServerStorage.UsedPositions
local Plate = game.ServerStorage.Plate:Clone()
Plate.Name = v.Name
Plate.Parent = workspace.Plates
Plate.Position = Position.Position
v.Character.HumanoidRootPart.CFrame = Plate.CFrame + Vector3.new(0, 5, 0)
v.TeamColor = game.Teams.Playing.TeamColor
end
wait()
repeat
PlayRandomEvent()
AlivePlayers = 0
for i, v in pairs(game.Players:GetChildren()) do
if v.TeamColor == game.Teams.Playing.TeamColor then
AlivePlayers += 1
end
end
if AlivePlayers <= 1 then
EndGame()
end
task.wait()
until IsIntermission == true
end
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to do everything and nothing worked, it seems im missing something