Swimmable part script won't work

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)
1 Like

try using

humanoid:ChangeState

SetStateEnabled apparently doesnt replicate to the client

1 Like

won’t work
111111111111111111111111111

1 Like

you also need water in there, because if u set it to swimming while there isnt water, it will automatically change it back

1 Like

what???
1111111111111111111111

1 Like

1 Like

just use the terrain tool to add some water to whatever youre trying to make

also, if youre adding water, theres no need for the script

just make the water invisible by setting

workspace.Terrain.WaterTransparency = 1
2 Likes

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