I want it so if a part is underwater it can get hidden so maybe if there’s a way to like hide the part under hull or waterline of ship.
I want it so if a part is underwater it can get hidden so maybe if there’s a way to like hide the part under hull or waterline of ship.
you want to hide the inside water of the boat?
Hiding a part is done with yourPartVariable.Transparency = 1.
If you want to hide parts that are submerged underwater, you will need to write up a function to check if the boat parts are fully inside the ocean part. This is actually quite complex, so I can’t write it for you without spending a lot of time on it.
If you want an easier solution, you can create an invisible AirPart above the OceanPart, and place the bottom of it a very tiny amount above OceanPart.
This should work as long as you are initializing the script before the boat is positioned on the map.
If your boat is in the world by default, you can temporarily move it outside of the map
.
local oceanPart = workspace:WaitForChild("OceanPart")
local airPart = workspace:WaitForChild("AirPart")
local boat = workspace:WaitForChild("Boat")
local function determinePartTransparency(part,isTouchingAir,isTouchingOcean)
if isTouchingAir.Value == false and isTouchingOcean.Value == true then
part.Transparency = 1
else
part.Transparency = 0
end
end
for index,part in pairs(boat:GetDescendants()) do
if not part:IsA("BasePart") then continue end
local isTouchingAir = Instance.new("BoolValue")
isTouchingAir.Name = "isTouchingAir"
isTouchingAir.Value = false
isTouchingAir.Parent = part
local isTouchingOcean = Instance.new("BoolValue")
isTouchingOcean.Name = "isTouchingOcean"
isTouchingOcean.Value = false
isTouchingOcean.Parent = part
airPart.Touched:Connect(function(hit)
if hit == part then
isTouchingAir.Value = true
end
end)
airPart.TouchEnded:Connect(function(hit)
if hit == part then
isTouchingAir.Value = false
end
end)
oceanPart.Touched:Connect(function(hit)
if hit == part then
isTouchingOcean.Value = true
end
end)
oceanPart.TouchEnded:Connect(function(hit)
if hit == part then
isTouchingOcean.Value = false
end
end)
isTouchingAir:GetPropertyChangedSignal("Value"):Connect(function()
determinePartTransparency(part,isTouchingAir,isTouchingOcean)
end)
isTouchingOcean:GetPropertyChangedSignal("Value"):Connect(function()
determinePartTransparency(part,isTouchingAir,isTouchingOcean)
end)
end
I’m not trying to hide parts underwater. I just want to make the water avoid going into the hull of the boat.
yes. So water does not appear inside boat
If the water is 1 big part then you can’t make a specific area of the part transparent without absurd levels of scripting. I can only think of very complex and laggy solutions. At that point you may as well script your own water physics.
Ideally you keep the boat above the water.
I don’t know how your boat is actually moving and staying afloat (you would need to send the script(s) that handle that), so I can’t say how exactly you should make it float better. You could make the boat slightly thicker so the water can’t penetrate.
We should have the roblox engine allow users to define “ObstructPart” or something so that parts have like a transparency to the user but they hide whatever is behind the camera, this could also allow stealth vehicles etc
Use A Script And Put In Terrain(Water Not Going In A Part Use Terrain:FillRegion)
