Hello, i have a water float script and it works perfectly fine but there is this one person that will not float. Is there a way to fix this? Here is my script:

local runInterval = 1 / 60 local humanoidFloatDamage = 15 local humanoidFloatDamageFrequency = 1.5 --local waterLevel = -12.5

local clippingPlaneDist = 0.5

--------------------------------[[ Running ]]-----------------------------------

local runService = game:GetService("RunService") local player = game.Players.LocalPlayer

local sGui = script.UnserwaterOverlay sGui.Image.Visible = false sGui.Parent = script.Parent.Parent

function newCharacter() local force = Instance.new("BodyPosition") force.D = 6 force.P = 180 local drag = Instance.new("BodyVelocity") drag.velocity = Vector3.new() drag.maxForce = Vector3.new(1, 0, 1) * 100 local dragRot = Instance.new("BodyAngularVelocity") dragRot.maxTorque = Vector3.new(1, 0, 1) * 100 dragRot.angularvelocity = Vector3.new()

local bodyMovers = {force, drag, dragRot}


local character = player.Character or player.CharacterAdded:wait()
local humanoid = player.Character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")
local camera = workspace.CurrentCamera

local mouse = player:GetMouse()

local floating = Instance.new("BoolValue", character)
floating.Name = "Floating"

local lastDamage = 0

local allParts = {}
local _a = {torso, character:WaitForChild("HumanoidRootPart"), character:WaitForChild("Head"), character:WaitForChild("Left Arm"), character:WaitForChild("Right Arm"), character:WaitForChild("Left Leg"), character:WaitForChild("Right Leg")}
for _, v in pairs(_a) do
	table.insert(allParts, {p = v, mass = v:GetMass()})
end

local characterMass = 0
for _, v in pairs(allParts) do
	characterMass = characterMass + v.p:GetMass()
end
local torsoOnly = {{p = torso, mass = characterMass}}


wait(1)


local function doGui()
	
	local dist, waterLevel = withinWaterBoundsXZ(camera.CoordinateFrame.p)
	local topFOV = dist < 0  and (camera.CoordinateFrame * CFrame.new(0, math.tan(camera.FieldOfView / 2) * clippingPlaneDist, -clippingPlaneDist)).p.Y
	local bottomFOV = dist < 0  and(camera.CoordinateFrame * CFrame.new(0, math.tan(camera.FieldOfView / 2) * -clippingPlaneDist, -clippingPlaneDist)).p.Y

	if dist < 0 and bottomFOV < waterLevel then
		sGui.Image.Visible = true
		
		if topFOV < waterLevel then
			sGui.Image.Position = UDim2.new()
		else
			local pos = (waterLevel - bottomFOV) / (topFOV - bottomFOV)
			sGui.Image.Position = UDim2.new(0, 0, 0, mouse.ViewSizeY - mouse.ViewSizeY * pos)
		end
	else
		sGui.Image.Visible = false
	end
end

local characterParts = torsoOnly
local dead = false
humanoid.Died:connect(function()
	characterParts = allParts
	dead = true
end)

local waterLevel 

while character.Parent do
	runService.RenderStepped:wait()

	--[[characterParts = torsoOnly
	if humanoid.Health <= 0 then
		characterParts = allParts
		dead = true
		wait()
	end ]]
	local healthSet
	
	for _, v in pairs(characterParts) do
		
		local dist, w = isInWater(v)
		waterLevel = w or waterLevel

		local existingForce = v.p:FindFirstChild("BodyPosition")
		if dist > 0 and not dead then
			if existingForce then
				for _, f in pairs(bodyMovers) do
					if v.p:FindFirstChild(f.Name) then
						v.p[f.Name]:Destroy()
					end
				end
				
				floating.Value = false
				sGui.Image.Visible = false
			end
			
			lastDamage = tick()
			
		elseif dist <= 0 or dead and floating.Value then

			if not existingForce then
				for _, f in pairs(bodyMovers) do
					if not v.p:FindFirstChild(f.Name) then
						if f.Name == "BodyPosition" then
							f.maxForce = Vector3.new(0, 4000 * v.mass, 0)
							f.position = Vector3.new(0, waterLevel + 0.5, 0)
						end
						f:clone().Parent = v.p
					end
				end
			else
				if v.p:FindFirstChild("BodyPosition") then
					v.p.BodyPosition.position = Vector3.new(0, waterLevel + 0.5, 0)
				end
			end
				
			floating.Value = true
			sGui.Image.Visible = true
			
			if not healthSet then
				healthSet = true
				if tick() - lastDamage > humanoidFloatDamageFrequency then
					game.ReplicatedStorage.Interaction.DamageHumanoid:FireServer(humanoidFloatDamage)
					lastDamage = tick()
				end
			end
		end
		
	end
	
	if dead then
		break
	end
	
	doGui()
end

while character.Parent do
	runService.RenderStepped:wait()
	doGui()
end

end

local waterParts = {}

function isInWater(v)

local dist, waterLevel = withinWaterBoundsXZ(v.p.Position)
if dist > 0 then
	return 1
else
	return dist, waterLevel
end

return 1

end

function withinWaterBoundsXZ(pos)

for _, part in pairs(waterParts) do
	if part.Transparency < 1 then
		local corner1 = part.CFrame * CFrame.new(part.Size / -2)
		local corner2 = part.CFrame * CFrame.new(part.Size / 2)
		local cornerSmall = Vector3.new(math.min(corner1.X, corner2.X), 0, math.min(corner1.Z, corner2.Z))
		local cornerBig = Vector3.new(math.max(corner1.X, corner2.X), 0, math.max(corner1.Z, corner2.Z))

		if pos.X > cornerSmall.X and pos.Z > cornerSmall.Z and pos.X < cornerBig.X and pos.Z < cornerBig.Z then
			
			local dist = pos.Y - part.CFrame.p.Y
			if dist < -40 then
				return 1
			end
			
			return dist, part.CFrame.p.Y
		end
	end
end

return 1

end

function getWater(perent) for _, v in pairs(perent:GetChildren()) do if v:IsA("BasePart") and (v.Name == "Water" or v:FindFirstChild("WaterForce")) then table.insert(waterParts, v) end getWater(v) end end getWater(workspace)

player.CharacterAdded:wait() player.CharacterAdded:connect(newCharacter) newCharacter()

3 comments

0

Like littlery one person doesnt float but all the rest do. how do i make the last person float?

0

And i just tried to change "localplayer" to the actual plyers name and nothing. He will not float

0

Im so confused can someone please help me? I added a kill on touch script to the water to see if that would work for now and he didnt die. He doesnt have god mode or anything?? here is the other scripts that i used                                                               function onTouched(part) if part.Parent:FindFirstChild("Humanoid") ~= nil then part.Parent.Torso:BreakJoints() end end

scr