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

This character body gyro script isn't working, and I have no idea how to fix it. Help??

I'm trying to make my character body turn left or right (not up and down) based on camera direction using a BodyGyro. I thought I knew how, but apparently, I don't know how because it's not working. No errors, it just doesn't move when I turn the camera (shocker, right?)

Here's what I have that's important. I was hoping I could come here to get some help since the forums shut down. I've tried everything and have no idea how to fix.

bodyGyro.CFrame = CFrame.new (game.Workspace.CurrentCamera.CFrame.lookvector.X, 0, game.Workspace.CurrentCamera.CFrame.lookvector.Z)  

The bodyGyro is in the torso, by the way.

2 comments

0

Is that in a localscript?

0

yes

1 answer

The CFrame.new constructor uses two parts: a position and an orientation. In this example, you want the position to be in the camera, and the orientation to be the direction the camera is looking. To make this orientation, you input a point in 3D space. Roblox makes the orientation by finding the orientation of a part at the position looking at the point you input. Conveniently, however, the camera already has a CFrame Property.

bodyGyro.CFrame = game.Workspace.CurrentCamera.CFrame

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