Re disabling humanoid state not working

I am working on a submarine game, where you explore the underwater sea life, and I am coding the submarine.
Whenever you enter and leave the submarine, it fires the client to enable/disable the swimming state.
Enabling it works, but when i enter back into the submarine, it doesn’t disable it, and I can swim freely inside the submarine.

--Client
local player = game.Players.LocalPlayer
local character =  player.Character or player.CharacterAdded:Wait()
local humanoid =  character.Humanoid
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)

game.ReplicatedStorage.inside.OnClientEvent:Connect(function(value)
	print(value)
	if value == true then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)
	else
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,true)
	end
end)
--Server
script.Parent.door.ProximityPrompt.Triggered:Connect(function(player)
	game.ReplicatedStorage.inside:FireClient(player,false)
	player.Character:PivotTo(script.Parent.door2.CFrame)

end)

script.Parent.door2.ProximityPrompt.Triggered:Connect(function(player)
	game.ReplicatedStorage.inside:FireClient(player,true)
	player.Character:PivotTo(script.Parent.door.CFrame)

end)
1 Like

do you have a video that you can show?

Here (sorry for the low quality

Hi, please try adding humanoid:ChangeState(Enum.HumanoidStateType.GettingUp) (or something else which would make sense, such as Landed, FreeFall, Running, etc.) after you Pivot the character inside. This should force-change the state to a walking one after getting inside, my guess is that the state remains as Swimming, even though it’s disabled.