I have already made everything and im not asking someone to just plain out give me the code but what ive tried is taking the humanoidrootpart away from the player and putting it in lighting right before the round starts and it still teleports the player to the map. I also tried putting a value inside a player to check if they have a vale of 1 which would mean they are AFK.
This is my games main script.
local repilcatedstorage = game.ReplicatedStorage
local status = game.ReplicatedStorage.InfoValue
local mapstorage = game.Workspace.mapStorage
while true do
while game.Players.NumPlayers < 2 do
status.Value = 'There needs to be 2 or more players to begin'
repeat wait(2) until game.Players.NumPlayers >= 2
end
for i = 90,0,-1 do
status.Value = 'Intermission '..i
wait(1)
end
_G.gameplayers = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v then
table.insert(_G.gameplayers, v.Name)
end
end
local mapsinserverstorage = game.ServerStorage:GetChildren()
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
chosenmap:Clone().Parent = mapstorage
status.Value = 'Round Beginning!'
wait(3)
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs (game.Players:GetPlayers()) do
if player and #spawns > 0 then
local torso = player.Character:WaitForChild('HumanoidRootPart')
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]
-- This right here is what I tried but still spawned the player into the map.
if game.Players.LocalPlayer.AFK.Value == 1 then
local torso = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart')
torso.Parent = game.Lighting
wait(1)
end
if randomspawn and torso then
table.remove(spawns, allspawns)
torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0))
local gun = game.ReplicatedStorage.Handgun
local newgun = gun:clone()
newgun.Parent = player.Backpack
end
end
end
for i = 120, 0, -1 do
if i == 0 then
status.Value = 'Round over!'
break
end
wait(1)
if #_G.gameplayers == 1 then
for i, v in pairs(_G.gameplayers) do
if v ~= nil then
status.Value = v..' is the winner!'
game.Players[v].leaderstats.Points.Value = game.Players[v].leaderstats.Points.Value + 50
--game.Players[v].leaderstats.Exp.Value = game.Players[v].leaderstats.Exp.Value + 50
break
end
end
break
else
status.Value = i..' seconds remaining!'
end
end
mapstorage:ClearAllChildren()
wait(5)
end

2 comments
Most inefficient way to check if there is less than 2 players.
I'm not asking that am I ? If you don't have anything to say about my question please just don't comment.