Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"CFrame expected, got Vector3"?

Asked by
Desmondo1 121
3 years ago

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

2 answers

Log in to vote
1
Answered by 3 years ago

change

Target + Vector3.new(0, i * 5, 0)

to

CFrame.new(Target + Vector3.new(0, i * 5, 0))

idk if this works, but if it works, then have a great day! stay safe.

0
If it doesn't work, please be more specific, what is the goal of this script and what are you actually trying to do? WINDOWS10XPRO 438 — 3y
0
If it doesn't work, please be more specific, what is the goal of this script and what are you actually trying to do? WINDOWS10XPRO 438 — 3y
0
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. Desmondo1 121 — 3y
0
Thanks a lot @WINDOWS10XPRO, it worked! Desmondo1 121 — 3y
0
You're welcome! Stay safe! WINDOWS10XPRO 438 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

change

Target + Vector3.new(0, i * 5, 0)

to

CFrame.new(Target + Vector3.new(0, i * 5, 0))

idk if this works, but if it works, then have a great day! stay safe.

Answer this question