i wanna make swimable part but script doesn’t work
here is script:
local waterPart = script.Parent
local function onTouched(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, true)
humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
end
end
local function onTouchEnded(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
end
end
waterPart.Touched:Connect(onTouched)
waterPart.TouchEnded:Connect(onTouchEnded)