I keep trying to make swimmable water in Roblox, and then it just turns into a failure. The animations won't work nor the user input service. I'm trying to make the water where you can basically swim dive down w/ shift and go up w/ space. Just doesn't work.
I answered this question a long time ago on the developer forum, so here's the gist:
You use a BodyVelocity with the MaxForce on each axis set to math.huge
and set the Velocity property to the current MoveDirection of their Humanoid (for this to work easily with mobile / console users too) multiplied by a desired speed (I used 16) to get the velocity. You just need to integrate diving / surfacing by using UserInputService to detect inputs and apply to the velocity, like:
local UP = 0 local Down = 0 UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.SpaceBar then UP = 1 elseif input.KeyCode == Enum.KeyCode.LeftShift then Down = 1 end end) -- // Handle InputEnded event and set the variables to 0 if the keys have been released local y = UP - Down BodyVel.Velocity = TargetedVelocity + Vector3.new(0, y, 0)
Doing this will give you the same results I did in this place long ago and even Flood Escape 2's