The code works fine until the maps gets clone into workspace, Im trying to pick a killer and teleport him to a part and the others will go to another spawn or part this is what I have so far
--By TheTopBoss local serverStorage = game:GetService("ServerStorage") local maps = serverStorage.Maps:GetChildren() h = Instance.new("Hint", game.Workspace) while true do if game.Players.NumPlayers >= 2 then --Choosing Map h.Text = "Game Will Start" ranMap = math.random(1, #maps) mapChosen = maps[ranMap] h.Text = "Map Chosen : ".. mapChosen.Name wait(3) mapChosenClone = mapChosen:Clone() mapChosenClone.Parent = game.Workspace wait(3) --Teleporting Players while true do wait(5) contestants = {} for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end end end if #contestants >= 2 then break else end while true do wait(1) RandomValue = math.random(1, #contestants) wait() RandomPlayerName = contestants[RandomValue] wait() h.Text = RandomPlayerName.." has been chosen as the killer!" wait(4) h.Text = "Teleporting all players to the map..." RandomPlayer = game.Players:FindFirstChild(RandomPlayerName) if RandomPlayer then RandomPlayer.Character.Torso.CFrame = CFrame.new(-1942.5, 311.89, 29.5) wait(5) for i, v in pairs(game.Players:GetPlayers()) do if v.Name ~= RandomPlayer.Name then v.Character.Torso.CFrame = CFrame.new(-2173.6, 316.69, 211.6) wait() end end end end -- Time Before Game ends for i = 10, 1, -1 do h.Text = "Time left : " .. i wait(1) end h.Text = "Game has ended" wait(3) mapChosenClone:Destroy() --Intermission time for i = 30, 1, -1 do h.Text = "Intermission : " .. i wait(1) end else h.Text = "More Players are needed" end wait() end
I think the issue is here:
while true do wait(1) RandomValue = math.random(1, #contestants) wait() RandomPlayerName = contestants[RandomValue] wait() h.Text = RandomPlayerName.." has been chosen as the killer!" wait(4) h.Text = "Teleporting all players to the map..." RandomPlayer = game.Players:FindFirstChild(RandomPlayerName) if RandomPlayer then RandomPlayer.Character.Torso.CFrame = CFrame.new(-1942.5, 311.89, 29.5) wait(5) for i, v in pairs(game.Players:GetPlayers()) do if v.Name ~= RandomPlayer.Name then v.Character.Torso.CFrame = CFrame.new(-2173.6, 316.69, 211.6) wait() end end end end
Since you're doing a loop and you're also picking the killer, you will end up picking more than one. If that isn't the issue, it could become it. Also, try putting:
print"Line 32 has executed"
Or something like that everywhere, especially where you think it'll break. That's a really good trick to find out where the problem is starting and how to fix it.