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

Invalid Argument #1 To 'New' (Vector3 Expected, Got Instance)?

Asked by 3 years ago

I'm making the part in a story game where you teleport to a vehicle when you touch a wall and I'm trying to use CFrame to teleport players but it keeps erroring

(This is a LocalScript inside of StarterPlayerScripts)

local Player = game:WaitForChild("Players").LocalPlayer
game.Workspace:WaitForChild("InsideContent")
game.Workspace:WaitForChild("Transportation")
game.Workspace.Transportation:WaitForChild("LeftSet")
game.Workspace.Transportation.LeftSet:WaitForChild("VanLeft")
game.Workspace.Transportation.LeftSet.VanLeft:WaitForChild("Seating")
local TP = game.Workspace.InsideContent.TPWallLeft
Player.CharacterAdded:Connect(function(char)
    local HRP = Player.Character:WaitForChild("HumanoidRootPart")
    TP.Touched:Connect(function(tpactive)
        local CFrame1 = CFrame.new(game.Workspace.Transportation.LeftSet.VanLeft.Seating.LeftChair1.LeftSeat1)
        local CFrame2 = CFrame.new(game.Workspace.Transportation.LeftSet.VanLeft.Seating.LeftChair2.LeftSeat2)
        local SeatNum = math.random(1,2)
        if SeatNum == 1 then HRP.CFrame = CFrame1
        elseif SeatNum == 2 then HRP.CFrame = CFrame2
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 3 years ago

You need to put a Vector3 value, not an instance. To get the Vector3 Position of the Seats, you add .Position to the end

game.Workspace.Transportation.LeftSet.VanLeft.Seating.LeftChair1.LeftSeat1.Position
game.Workspace.Transportation.LeftSet.VanLeft.Seating.LeftChair2.LeftSeat2.Position
0
Thank you! You helped me solve the last bit of a very long line of errors I'd been facing for days SuperSM1 67 — 3y
0
:D JustinWe12 723 — 3y
Ad

Answer this question