Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make humanoid swim without terrain water?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago

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)
Ad

Answer this question