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

How to make humanoid swim without terrain water?

I've been trying and looking everywhere. So far I only got this from an old question someone asked a while ago.

while wait() do
game.Players.LocalPlayer.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
end

I've used it but it ain't smooth, the animation doesn't play smoothly and its as if the character is swapping between walking and swimming in an instant. Its also jerking around.

Is there any way to make the character swim in the air as if the air was water? Thanks.

1 answer

You would need to manage the enabling and disabling of the humanoid states yourself.

You should avoid using infinite loops where possible and use events such as StateChanged

A quick local script example in StarterCharacterScripts:-

local hum = script.Parent:WaitForChild('Humanoid')
for _, v in pairs(Enum.HumanoidStateType:GetEnumItems()) do  -- loop all humanoid state enums
	if v ~= Enum.HumanoidStateType.None then	 -- none cannot be disabled and will error if you try
	    hum:SetStateEnabled(v, false)  -- disable the given state
	end
end

hum:ChangeState(Enum.HumanoidStateType.Swimming) -- force the humanoid state (even thought is disabled)

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