im trying to have a model float in custom made water, the script for a single part works just fine, but I attempted to do this for a model but it wont work like a single part.
this is a script for a single part, it does work:
script.Parent.Touched:Connect(function()end)
local debounce = false
local isfound = false
while true do
wait()
if not debounce then
debounce = true
local results = script.Parent:GetTouchingParts()
for _, p in next, results do
if p.Name == "WaterPart" then
isfound = true
local forcemover = script.Parent.WaterForce
local part = script.Parent
forcemover.force = Vector3.new(0, 196.2, 0) * part:GetMass()
end
end
wait()
if isfound == false then
local forcemover = script.Parent.WaterForce
local part = script.Parent
forcemover.force = Vector3.new(0, 0, 0)
end
debounce = false
wait(0.09)
if isfound == true then
isfound = false
end
end
end
this is the model version that does not work:
script.Parent.Touched:Connect(function()end)
local debounce = false
local isfound = false
while true do
wait()
if not debounce then
debounce = true
local results = script.Parent:GetTouchingParts()
for _, p in next, results do
if p.Name == "WaterPart" then
isfound = true
--get mass of model--
function GetMassOfModel(model)
local mass = 0
for i, v in pairs(model:GetChildren()) do
if v:IsA('BasePart') then
mass = mass + v:GetMass()
local forcemover = script.Parent.WaterForce
forcemover.force = Vector3.new(0, 196.2, 0) * mass
end
end
end
---------------------
end
end
wait()
if isfound == false then
local forcemover = script.Parent.WaterForce
local part = script.Parent
forcemover.force = Vector3.new(0, 0, 0)
end
debounce = false
wait(0.09)
if isfound == true then
isfound = false
end
end
end
