I am trying to make a script that spawns a brick in front of me but I have no idea how xD
This is the best I can come up with
a = Instance.new("Part", workspace) a.Anchored = true a.Position = game.Players.LocalPlayer.Character.Torso.Position
But that spawns it at my Torsos position I want it to spawn in front of me
Thanks
In essence, you are asking how to find a location in front of a part, then place a part there. Sigive10's answer is incorrect, as the front of something is relative to the object, not world coordinates which his example provides.
First, you'll want to place your part where your torso is, so:
Brick.Position = Torso.Position
Next, you'll want to get the direction your Torso is pointing. Otherwise, it wouldn't be 5 studs in front of the Torso, but rather exactly where the Torso is located. Thankfully, Roblox provides a very easy way to do this: the CFrame property lookVector, which returns a vector pointing forward from the front face of any CFrame.
We add this vector to the Brick's position:
Brick.Position = Torso.Position + Torso.CFrame.lookVector
As lookVector is a unit vector, it is one stud 'long' in simple terms, thus to get it to 5 studs in length, we can mutiply it by 5:
Brick.Position = Torso.Position + Torso.CFrame.lookVector * 5
And there we are, you have a brick 5 studs in front of the torso.
Here you go
a = Instance.new("Part", workspace) a.Anchored = true a.Position = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0,0,-5)
There ya go. You just have to add the Vector3 that you want to the Vector3 that you have. In that way it spawns a Vector3 amount of offset from the character