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

positioning a part a certain amount of studs in front of another parts lookvector?

Asked by 5 years ago
local part = Instance.new("Part")

part.Parent = game.Workspace

part.Anchored = true

part.CFrame = CFrame.new(script.Parent.CFrame.LookVector * 5)

I wanted to change a parts position a certain distance from another parts LookVector, so I Created a test script to see if what I had in mind would work. it did not work and no error came up. can someone show me the correct way to do this?

1 answer

Log in to vote
0
Answered by 5 years ago

LookVector * 5 + Vector3.new(#,#,#) will add the number onto the position

0
local part = Instance.new("Part") part.Parent = game.Workspace part.Anchored = true part.CFrame = CFrame.new(script.Parent.CFrame.LookVector * 5 + Vector3.new(0,0,-3)) is this what you mean? mantorok4866 201 — 5y
0
exacly Gameplayer365247v2 1055 — 5y
0
the part only spawns in the same spot at the center of the workspace. mantorok4866 201 — 5y
0
are you sure about that because this is how it went for me, this is without the vector3 https://imgur.com/a/8Z41bBN and https://imgur.com/a/qYv4JpS this is how it went with vector3 https://imgur.com/a/jRHtyvn and https://imgur.com/a/hWvpxep Gameplayer365247v2 1055 — 5y
View all comments (2 more)
0
after looking over your results the position was in fact the same as yours, but its still relativly in the center of the workspace. I tried playing around with the values and moved "script.Parent" in different positions but the new part always goes to the world center. im just trying to get the new part to spawn maybe 5 studs in front of "script.Parent" mantorok4866 201 — 5y
0
I finally found a solution. we were both doing it wrong: local part = Instance.new("Part") print(part.Name) part.Parent = game.Workspace part.Anchored = true part.Position = script.Parent.Position + script.Parent.CFrame.LookVector * 3 print(part.Position) mantorok4866 201 — 5y
Ad

Answer this question