Can't Teleport a player?
I'm trying to teleport a player ~50 studs in front of where the camera is looking at, whenever they double tap the "w" key. I know how to teleport the player and find the direction of the camera (At least I think I'm doing it right, I could be wrong), but I can't seem to put them together without getting the same error:
15:33:11.773 - Players.McQuakyDuck.PlayerGui.LocalScript:37: bad argument #2 to '?' (Vector3 expected, got number)
All the code is in a LocalScript inside of StarterGui
02 | game.Players.PlayerAdded:connect( function (player) |
03 | script.LocalScript:clone().Parent = player.CharacterAdded:wait() |
08 | local cam = workspace.CurrentCamera |
09 | local player = game.Players.LocalPlayer |
10 | game.Workspace:WaitForChild(player.Name) |
11 | local Char = player.Character |
12 | local Humanoid = Char:WaitForChild( "Humanoid" ) |
13 | local Mouse = player:GetMouse() |
16 | local Trail = game.Workspace.Trail:Clone() |
18 | local Mouse = player:GetMouse() |
25 | Mouse.KeyDown:connect( function (key) |
26 | if not enabled and clicked then |
29 | if key = = "w" and _G.Energy > = 25 then |
32 | local function onTap() |
33 | if tick() - lastTapTime < 0.2 then |
34 | print ( "double Click!" ) |
37 | player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector 3 (cam.CFrame.lookVector + 50 ,cam.CFrame.lookVector + 50 ,cam.CFrame.lookVector + 50 )) |
39 | Trail.Parent = Char.HumanoidRootPart |
40 | local attachment 0 = Instance.new( "Attachment" , Char.Head) |
41 | attachment 0. Name = "TrailAttachment0" |
42 | local attachment 1 = Instance.new( "Attachment" , Char.HumanoidRootPart) |
43 | attachment 1. Name = "TrailAttachment1" |
44 | Trail.Attachment 0 = attachment 0 |
45 | Trail.Attachment 1 = attachment 1 |
Any help is appreciated!