New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# How to use lookVector to orientate a new part? [SOLVED]

Edited by BashCaster 3 months ago

For simplicity lets say i am creating a new WedgePart in front of the player. How do i rotate the new part so that it is facing the same direction as the player?

I tried .Orientation as per the code below, however this rotates relative to the map xyz. The best i can figure on my own is that i need to use the lookvector of the player, however never using one yet i have failed to get anywhere.

local part = Instance.new('WedgePart', game.Workspace)
part.Name = 'Slope'
part.CFrame = player.Character.PrimaryPart.CFrame * CFrame.new(0,0,-5)
part.Size = Vector3.new(10,15,15)
part.Orientation = Vector3.new(0,180,0)
part.BrickColor = BrickColor.Random()
part.CanCollide = true
part.Anchored = true
part.Material = 'Plastic'

0
i had already spent ages trying to figue what was posted there out, i just took another look at it though and finally made sense of it. it wasn't specifcally what i needed but the answer was within the script there, so thanks for prompting me to have another look. Yishles 4 — 3mo
0
It happens for the best, stay strong in the scripting world. Serpawh -4 — 3mo

0

Simply needed to add cframe.angles argument, and remove orientation. fixed code is below for anyone who needs it. Just change the angles on the end of line 3 to rotate.

local part = Instance.new('WedgePart', game.Workspace)
part.Name = 'Slope'
part.CFrame = player.Character.PrimaryPart.CFrame * CFrame.new(0,0,-5) * CFrame.Angles(0,math.rad(180),0)
part.Size = Vector3.new(10,15,15)
part.BrickColor = BrickColor.Random()
part.CanCollide = true
part.Anchored = true
part.Material = 'Plastic'