Hello! I’m trying to make a battle arena game and I’m having trouble with the character selection process.
There are 2 stages of the game. The Lobby and the actual game.
I want to make sure that a player selects a character in order to be teleported into the actual game which as you can see I have tried to do below.
local maps = game:GetService("ServerStorage").Maps:GetChildren()
local Title = game.StarterGui.MapSelector.Title
local spawns = game.Workspace.Spawns:GetChildren()
local status = game.ReplicatedStorage.Status
local Server = game.ReplicatedStorage.SERVER
ti = 0
Server.Value = "IDLE"
while true do
ti = 30
repeat
ti = ti -1
status.Value = "Intermission "..ti
wait(1)
until ti == 0
local randomMap = maps[math.random(1, #maps)]
randomMap:Clone().Parent = workspace
current = randomMap.Name
status.Value = "Loading.."
task.wait(1)
status.Value = "Starting game"
task.wait(1.5)
Server.Value = "GAME"
local plrs = game.Players:GetChildren()
for i = 1, #plrs do
local randomSpawn = spawns[math.random(1, #spawns)]
if plrs[i].Character.ready.Value == true then
plrs[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position)
plrs[i].Character.status.Value = "ingame"
end
end
ti = 30
repeat
ti = ti -1
status.Value = ti
wait(1)
until ti == 0
for i = 1, #plrs do
plrs[i].Character.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0, 10, 0)
plrs[i].Character.status.Value = "lobby"
Server.Value = "IDLE"
end
workspace[current]:Destroy()
end
The only problem is that if the player chooses a character a bit late or not within those 30 seconds of intermission they wonted be teleported. How would I fix this?