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 make this camera follow script disregard the Y axis?

I'm stumped on how to make my script disregard the Y axis on my player. (When I jump, it shouldn't follow me)

local part1 = game.Workspace.Part1
repeat wait() until workspace.Player
local part2 = workspace.Player
while true do
part1.BodyGyro.cframe = CFrame.new(part1.Position,part2.Torso.Position)
wait()
end

1 answer

✓ Accepted answer

I created a new CFrame for the direction of the BodyGyro. It's the same as the old CFrame, but I used part1.CFrame's "Y" component in place of part2.Torso.CFrame's.

part1.BodyGyro.cframe = CFrame.new(part1.Position, (CFrame.new(part2.Torso.CFrame.X, part1.CFrame.Y, part2.Torso.CFrame.Z)).p)

This is one of the many ways to do this. I hope this answers your question.


Edit:

Lol, I could've just as easily have done this.

part1.BodyGyro.cframe = CFrame.new(part1.Position, Vector3.new(part2.Torso.Position.X, part1.Position.Y, part2.Torso.Position.Z))

2 comments

0

error: Workspace.Script:5: bad argument #2 to 'new' (Vector3 expected, got CFrame)

0

I'm sorry. I misplaced the closing parenthesis. It should work now.

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