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

How do I make this camera follow script disregard the Y axis?

Asked by 9 years ago

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

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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))
0
error: Workspace.Script:5: bad argument #2 to 'new' (Vector3 expected, got CFrame) HungryJaffer 1246 — 9y
0
I'm sorry. I misplaced the closing parenthesis. It should work now. Redbullusa 1580 — 9y
Ad

Answer this question