Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I rotate an Instance.new Part?

Asked by 13 days ago

I have this Instance.new part and I changed most of it's properties except I'm not exactly sure how I would rotate it.

local Blast = Instance.new("Part")
Blast.Name = "Blast"
Blast.Shape = Enum.PartType.Block
Blast.Size = Vector3.new(9.38, 0.29, 0.26)
Blast.Material = Enum.Material.Neon
Blast.BrickColor = BrickColor.new("Toothpaste")
Blast.CanCollide = false
Blast.Parent = game.Workspace
Blast.Transparency = 0
Blast.Orientation = Vector3.new(0,0,90) --What I'm having trouble with
Blast.CFrame =     Character.HumanoidRootPart.CFrame*CFrame.new(0,0,0)
0
You have to be a little more specific. How do you want to rotate it? Upside down? Point towards another part? etc. RayCurse 1298 — 13d
0
You can multiply the part’s CFrame. Part.CFrame = Part.CFrame * CFrame.Angles(0,0,math.rad(90)). Rheines 552 — 13d

1 answer

Log in to vote
0
Answered by 13 days ago
Edited 13 days ago

You would use CFrame.Angles(). Here are the following dimensions and how the part would spin (assuming the part is parallel to the Baseplate):

  1. X - The part spins parallel to the Baseplate on its center. (It spins as if it were on a Motor.)
  2. Y - The part spins perpendicular to the Baseplate with a spin from negative to positive Y (unless a negative number is given).
  3. Z - The part spins perpendicular to the Baseplate with a spin from negative to positive Z (unless a negative number is given).

Here's an example of rotating a part:

local part = Instance.new("Part")
part.Parent = workspace
part.Position = workspace.Baseplate.Position + Vector3.new(0,10,20)
while true do
    wait(0.1)
    part.CFrame = part.CFrame * CFrame.Angles(0,0, math.rad(10))
end

CFrame.Angles() uses radians, so in order to rotate the part you would use math.rad().

Ad

Answer this question