local person = game.Players.LocalPlayer local body = person.Character local humanoidr = body:WaitForChild("HumanoidRootPart") local humanoidp = body:WaitForChild("Humanoid") local folder = workspace:FindFirstChild(person.Name) if folder then local uw = folder:FindFirstChild("UnderwaterDetection") if uw then uw:Destroy() end end local ocean = workspace:FindFirstChild("OceanTile1") local wavemath = require(game.ReplicatedStorage.WaveMath) local floatForce local function keepAboveWater() local pos = humanoidr.Position local waveY = ocean.Position.Y + math.abs(ocean.Position.Y) + wavemath.GetPosition(pos.X,pos.Z,workspace:GetServerTimeNow()).Y if pos.Y < waveY then if not floatForce then floatForce = Instance.new("VectorForce") floatForce.Name = "floatForce" floatForce.Attachment0 = humanoidr.RootAttachment floatForce.RelativeTo = Enum.ActuatorRelativeTo.World floatForce.Parent = humanoidr end local mass = humanoidr.AssemblyMass floatForce.Force = Vector3.new(0, math.clamp(mass*150*(waveY-pos.Y),0,mass*2000),0) humanoidp:ChangeState(Enum.HumanoidStateType.GettingUp) elseif floatForce then floatForce:Destroy() floatForce = nil end end game:GetService("RunService").Heartbeat:Connect(keepAboveWater) body:WaitForChild("IsRagdoll").Changed:Connect(function() humanoidp:ChangeState(Enum.HumanoidStateType.GettingUp) end)