Hey Developers,
I know this title is weird, but there isn’t really anything else I can call it.
So I am expierencing this extremely weird issue. I get no errors at all. My round works with one player, but when there’s two, it doesn’t teleport the players at all. When the intermission timeout reaches 0 it just stops.
I have a module script and a normal script
Module script:
local module = {}
local status = game.ReplicatedStorage:WaitForChild('Status')
function module.Intermission(length)
for i = length,0,-1 do
status.Value = 'Next round starts in '..i..' seconds'
wait(1)
end
end
function module.SelectChapter()
local rand = Random.new()
local chapters = game.ReplicatedStorage.Chapters:GetChildren() -- Table of all map models
local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
return chosenChapter
end
function module.ChoosePiggy(players)
local RandomObj = Random.new()
local chosenPiggy = players[RandomObj:NextInteger(1,#players)]
return chosenPiggy
end
function module.DressPiggy(piggy)
local character = game.ServerStorage.Piggy:Clone()
character.Name = piggy.Name
piggy.Character = character
character.Parent = workspace
end
function module.TeleportPiggy(player)
if player.Character then
player.Character.Humanoid.WalkSpeed = 10
local bat = game.ServerStorage.Tools.PiggyBat:Clone()
bat.Parent = player.Character
if player.Character:FindFirstChild('HumanoidRootPart') then
player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.PiggyWaitingSpawn.CFrame + Vector3.new(0,5,0)
end
end
end
function module.TeleportPlayers(players, mapSpawns)
for i, player in pairs(players) do
if player.Character then
local character = player.Character
if character:FindFirstChild('HumanoidRootPart') then
player.Character.Humanoid.WalkSpeed = 11
local rand = Random.new()
player.Character.HumanoidRootPart.CFrame = mapSpawns[rand:NextInteger(1,#mapSpawns)].CFrame + Vector3.new(0,10,0)
end
end
end
end
function module.InsertTag(contestants,tagName)
for i, player in pairs(contestants) do
local Tag = Instance.new('StringValue')
Tag.Name = tagName
Tag.Parent = player
end
end
local function toMS(s)
return ("%02i:%02i"):format(s/60%60, s%60)
end
function module.StartRound(length,piggy,chapterMap)
for i = length,0,-1 do
if i == (length - 20) then
module.TeleportPlayers({piggy}, chapterMap.PlayerSpawns:GetChildren())
status.Value = 'Piggy has woken up!'
wait(2)
end
status.Value = toMS(i)
wait(1)
end
end
return module
Normal Script:
local Round = require(script.RoundModule)
local Door = require(script.DoorModule)
Round.Intermission(30)
local chosenChapter = Round.SelectChapter()
local clonedChapter = chosenChapter:Clone()
clonedChapter.Name = 'Map'
clonedChapter.Parent = game.Workspace
if clonedChapter:FindFirstChild('Doors') then
Door.ActivateDoors(clonedChapter.Doors)
else
warn('Test')
end
local contestants = {}
for i, v in pairs(game.Players:GetPlayers()) do
if not v:FindFirstChild('InMenu') then
table.insert(contestants,v)
print('added: '..v.Name.. 'Into the table')
end
end
local chosenPiggy = Round.ChoosePiggy(contestants)
for i, v in pairs(contestants) do
if v == chosenPiggy then
print(v.Name)
table.remove(contestants,i)
else
game.ReplicatedStorage.ToggleCrouch:FireClient(v,true)
end
end
print('Continuing')
Round.DressPiggy(chosenPiggy)
Round.TeleportPiggy(chosenPiggy)
if clonedChapter:FindFirstChild('PlayerSpawns') then
Round.TeleportPlayers(contestants, clonedChapter.PlayerSpawns:GetChildren())
else
warn('Test')
end
Round.InsertTag(contestants,'Contestant')
Round.InsertTag({chosenPiggy}, 'Piggy')
Round.StartRound(600,chosenPiggy,clonedChapter)
Like I’ve already said, I get no errors. No idea what to do to fix this, as it’s a major issue.
Thanks.