I'm setting up a swimming system where you can't Swim past the OceanLevel(being the Y height of the water maximum) As it is, its really jittery and I've tried ways in making it smooth(no jittery motions) but its always crashed the script(not the game)
OceanLevel.Value = -12.1 Angle is the Y angle of the players camera movement.(whichever movement) == 1(means true) Feel like its the way "Player.Character:MoveTo" works that makes it jittery but that's a personal assumption
if (script.IsSwimming.Value == true and Human.Position.Y > OceanLevel.Value and angle >= 0) or (script.IsSwimming.Value == true and Human.Position.Y > OceanLevel.Value and angle <= 0 and movement.backward == 1) or (script.IsSwimming.Value == true and Human.Position.Y > OceanLevel.Value and angle <= 0 and movement.upward == 1) or (script.IsSwimming.Value == true and Human.Position.Y > OceanLevel.Value and angle <= 0 and movement.upward == 1 and movement.forward == 1) then Player.Character:MoveTo(Vector3.new(Human.Position.X, OceanLevel.Value, Human.Position.Z)) end
Any advice/tips on fixing this would be a great help!
Not sure if this is the answer you’re looking for but if moving a few pixels is alright you can always set a BodyPosition that can only move on the y axis. Using heartbeat like that comment said would work too since I believe it runs every time the game renders.