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

How to make a brick rotate around a brick?

Asked by 6 years ago

Im going to make a hat with effect and I need to make a brick rotate around it. How do i do it? Im not so good at scripting.

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Basically, you set the position of the brick to be the part that you want to rotate around, then add an offset multiplied by a rotation.

local hat = -- hat reference
local effect = -- effect reference

local distanceFromHat = 5

while true do
    for i = 1, 360 do
        effect.CFrame = hat.CFrame * CFrame.Angles(0, math.rad(i), 0) * CFrame.new(Vector3.new(distanceFromHat, 0, 0))
        wait()
    end
end

So quick rundown of the math behind it:

The effect is offset 5 units to the right of the hat, but we multiply the current angle i to the hat so the effect rotates along with it. The hat doesn't actually move but that's the math behind it.

It should net you a result like this.

Hope this helps! :)

0
Thank you very much! :) xxxpegasus1337 4 — 6y
Ad

Answer this question