Add 2 onto the X value of a vector3

I’m trying to make a detain tool and I’m having trouble teleporting the detainee in front of the player. How would I get the players position and then add 2 onto the X value? I’ve looked around but I can’t find anything.

TL;DR, How do I add 2 onto a vector3 X value

2 Likes

You can just create a new Vector3 value with the value of X set to 2 and add that to player’s position.

local HumanoidRootPart = --Put the reference to HumanoidRootPart here
HumanoidRootPart.Position += Vector3.new(2, 0, 0)
2 Likes

It’s now just teleported itself to the X position of 2.

Nevermind that was a problem with my script not yours.