Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

Thank you! You helped me solve the last bit of a very long line of errors I'd been facing for days

0

:D

This discussion is preserved as it was. New answers, comments, and votes are closed.