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

How do I use bodygyro to rotate a object with a specific surface?

Asked by 7 years ago

Okay, so I have a sword mesh and I want it to point to me using the top surface. Is there a way to do that. I've already got it working to rotate to me but not how I want it. I want it to look like its pointing the tip of the sword to me not its side.

bg = script.Parent.BodyGyro
while true do
    wait(0.1)
bg.cframe = CFrame.new(script.Parent.Position,game.Workspace.Player1.Torso.CFrame.p );

end

If there is any way to do this I would like to know.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Since I don't know what sword model you're using, I can't give you the exact solution, but I can tell you how to fix it. You simply rotate your existing CFrame like so:

bg = script.Parent.BodyGyro
while true do
    wait()
    bg.CFrame = CFrame.new(script.Parent.Position,game.Workspace.Player1.Torso.CFrame.p ) * CFrame.Angles(math.rad(180), 0, 0)
end

Note that this code is for the Roblox sword, and since your sword is different you will have to play around with the angles of the second CFrame; I would set them to multiples of 90 degrees (don't forget to use math.rad if you're giving the angles in degrees).

0
THANK YOU ickeyben123 22 — 7y
Ad

Answer this question