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)