Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

Thanks in advance.

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'

3 comments

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.

0

It happens for the best, stay strong in the scripting world.

1 answer

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'

This discussion is preserved as it was. New answers, comments, and votes are closed.