Humanoid:ChangeState(Swiming) not worky?

I’am making swimable part , but the ChangeState function is not work with HumanoidStateType.Swimming here’s code

local water = script.Parent
local hits ={}


function check(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
		return hit.Parent["Humanoid"] , hit.Parent["HumanoidRootPart"]
	end
end


water.Touched:Connect(function(hit)
	local hum,humrp = check(hit)
	if hum and humrp and not table.find(hits,hit.Parent) then
		    hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
		hum:ChangeState(Enum.HumanoidStateType.Swimming)
		
		table.insert(hits,hit.Parent)
		print(hum:GetState())
	end
end)


water.TouchEnded:Connect(function(hit)
	local hum,humrp = check(hit)
	if hum and humrp and  table.find(hits,hit.Parent) then
		print("removed")
		table.remove(hits,table.find(hits,hit.Parent))
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
		hum:ChangeState(Enum.HumanoidStateType.GettingUp)
	end
end)

Is this a local script? if not, change it to one. That’s the only problem I can think of. States are handled by the client, and cannot be changed properly on the server.

hmm… I tested it and it not work

the state should be looped and all other states should be disabled since the change state changes only once and instantly after that it goes back to the state your character was

so the script type will be client and ima add loop outside hum:ChangeState()?