I have a script were it makes a top down view and makes the character look to the mouse. I'm having a problem were when the player jumps, he kind of spazzes out. I had a idea were i could just get the Y
position of Mouse.Hit.p
, but then it doesn't work. Any help?
Script:
wait() --------------- --[Variables]-- --------------- local currentZoom = 10 local currentX = 0 local currentY = 15 local cam = game.Workspace.CurrentCamera local plr = game.Players.LocalPlayer repeat wait() until plr.Character local char = plr.Character game.Workspace.CurrentCamera.CameraType = "Scriptable" ---------------------------- --[Instance Creation Area]-- ---------------------------- local Gyro = Instance.new("BodyGyro",char.Torso); Gyro.maxTorque = Vector3.new(0,100000,0); Gyro.P = 10000 Gyro.D = 250 local Mouse = game.Players.LocalPlayer:GetMouse(); --------------- --[Functions]-- --------------- plr.CharacterAdded:connect(function (newchar) char = newchar end) --Top down view manager game:GetService("RunService").RenderStepped:connect(function() if char:findFirstChild("Head") then cam.CoordinateFrame = CFrame.new((char.Head.Position + Vector3.new(currentX, currentY, currentZoom)),char.Head.Position) end if char:findFirstChild("Torso") then Gyro.cframe = CFrame.new(char.Torso.Position,Mouse.Hit.p) end end)
Edit: I noticed that, when i lower the maxTorque
to 0,10000,0
(original 0,100000,0
), and i jump while i'm looking at the opposite direction of were i'm moving (lets say, i'm jumping while moving to left, but looking at the right ), the character slowly looks to the direction on were he's moving and when he hit the ground, he looks back to the mouse.