How to know when the player stop Swimming

Hi, how can I know when the player stops swimming?

Is there’s a humanoid state type for that?

1 Like

Here,

if Humanoid:GetState() == Enum.HumanoidStateType.Swimming then

end

Im not sure exactly how this will turn out. Also when you mean stop swimming, are you talking about getting on land? If its in water, You can find if the player is moving

1 Like

I’m talking about getting on land, i tried with the state “Landed”, but it change some values that i have for the player.

1 Like

Example:

I have these values for the player.
image

When the player is swimming, the values turn to false.

But if I use the state “landed,” the values always change to the default values, disturbing some functions.

1 Like

What do you mean by default values

The values inside this table:

image

But wait, i have an idea.

1 Like

The landed state only fires when you hit the ground from falling. I don’t think you want to use it for ‘stopped swimming’

The best way is as @X0BaconHairDude0X said, check the swimming state, or
you can check for the event.

Humanoid.Swimming:Connect …
and
Humanoid.Running:Connect …

Running fires whenever the humanoid is standing or moving on land.

2 Likes

So, i did this and it worked:

Humanoid.StateChanged:Connect(function(Swimming)
	if Swimming == Enum.HumanoidStateType.Swimming then
		Values.IsSwimming = true
	else
		Values.IsSwimming = false
	end
end)

I think there’s a better way, but this was a fast solution i found.

1 Like

Im glad it worked, a better way may be harder to find but at least you have an solution

1 Like

You got me the idea with the code you send, Tysm.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.