This tutorial covers how to make a character swim outside of terrain water. I struggled with this for a bit and the question seems to be mostly unanswered on this forum, so I’m providing a solution here. This code should make a character swim as if they were in terrain water.
The following lines should be placed in a local script. Humanoid
references the Humanoid object in the players character.
When you want to make the character start swimming:
Humanoid:SetStateEnabled("GettingUp", false)
Humanoid:ChangeState("Swimming")
The GettingUp
state must be disabled because the roblox character will automatically get up if it is swimming and not in terrain water.
Then, when you want the character to stop swimming, just call
Humanoid:SetStateEnabled("GettingUp", true)
The character will automatically get up if it is not in water.