I’m trying to make a ball with a weight in the bottom hemisphere–when the ball touches water, the weight inside it keeps it upright. I figured the easiest way to do it would be to put an invisible, no-collision part inside the water that triggers the masslessness, and while I figured out how to disable the masslessness on touch, I haven’t figured out how to re-enable the masslessness when the touch ends.
Here’s the code I have for the part inside the water:
function onTouched(hit)
if not hit or not hit.Parent then return end
local human = hit.Parent:findFirstChild("Humanoid")
if human and human:IsA("Humanoid") then
human.Parent.Weight.Massless = false
end
end
function onTouchEnded(hit)
if not hit or not hit.Parent then return end
local human2 = hit.Parent:findFirstChild("Humanoid")
if human2 and human2:IsA("Humanoid") then
human2.Parent.Weight.Massless = true
end
end
script.Parent.Touched:connect(onTouched)
script.Parent.TouchEnded:connect(onTouched)
What would I do to re-enable the masslessness on touch end? If you have an idea that doesn’t require me to put this script in every “water” part (the part that goes in the water that triggers this) and only goes in the ball part itself, please let me know.