This script has to be done on client. You can’t make player swim on server.
local Swim = nil
En.Swim.Event:Connect(function(X,Y,Z,Char)
local humanoid = Char.Humanoid
local Root = Char.HumanoidRootPart
if Engine.IsFluid(X,Y,Z) then
Swim = Instance.new("BodyVelocity")
Swim.Parent = Root
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
else
Swim:Destroy()
Swim = nil
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
end
end)
game:GetService("RunService").RenderStepped:Connect(Function()
if not Swim then
return
end
Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
end)