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

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

Asked by 5 years ago
Edited by DeceptiveCaster 5 years 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.

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'
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 — 5y
0
It happens for the best, stay strong in the scripting world. Serpawh -4 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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'
Ad

Answer this question