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

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

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

✓ Accepted answer

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).

1 comment

0

THANK YOU

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