Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do we make swimmable water? (Not Terrain Water)

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.

1 comment

0

You can send me the coding but I prefer coding it myself, If you send the code to me i'll just learn from it and code it.

1 answer

✓ Accepted answer

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

1 comment

0

Thank you sir!

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