I'm making a round system with a random map selector. I keep getting this error: "CFrame expected, got Vector3", I have tried using CFrame and it gives practically the same error: "Vector3 expected, got CFrame", Heres my code:
local MapsFolder = game.Lighting.Maps local Maps = MapsFolder:GetChildren() local IntermissionTime = script.IntermissionTime local Message = Instance.new("Hint")
while true do
local ChosenMap = Maps[math.random(1, #Maps)]
local MapClone = ChosenMap:Clone()
wait(IntermissionTime.Value)
Message.Parent = game.Workspace
Message.Text = "Map Chosen: "..ChosenMap.Name
wait(5)
if _G.InsideBossBattle == true then -- The bool value here becomes true when a player beats the obby
Message.Parent = game.Lighting
return
end
if ChosenMap.Name == "FloorIsLava" then
local Target = Vector3.new(-336.78, 11.12, 128.1)
for i, player in ipairs(game.Players:GetChildren()) do -- Referencing all the players
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = Target + Vector3.new(0, i * 5, 0) -- Teleporting all the players
end
end
end
if ChosenMap.Name == "Temple" then
local Target = Vector3.new(83.9, 29.3, 142.6)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = Target + Vector3.new(0, i * 5, 0)
end
end
end
if ChosenMap.Name == "Nature" then
local Target = Vector3.new(53.86, 44.4, 512.42)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = Target + Vector3.new(0, i * 5, 0)
end
end
end
MapClone.Parent = game.Workspace
MapClone:MakeJoints()
if _G.InsideBossBattle == true then
MapClone:Destroy()
end
end

5 comments
If it doesn't work, please be more specific, what is the goal of this script and what are you actually trying to do?
If it doesn't work, please be more specific, what is the goal of this script and what are you actually trying to do?
The goal is to make a system where every 30 seconds a random map would be chosen. That part works. Then after a player wins the round, they get teleported back into the lobby. I'm gonna make it teleport them back after I fix the first problem. Which is I can't teleport the players into the round.
Thanks a lot @WINDOWS10XPRO, it worked!
You're welcome! Stay safe!