I’m trying to make it so if a part touches water, it changes colour or any property really and then when out of water it changes back to the original colour. Any info on how to do that?
.Touched
Is most likely what you are looking for.
https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched
You can also use Region3’s but that may not be as great of an option depending on what you are doing.
you can’t material by touched.
You have to use raycast to do it!
but i have a simple suggestion and use Touched event. You need create invisible hitboxes where there is water, giving them a specific name like “Water”.
put the following script in the part you want and edit it a bit.
local part= script.Parent
--------------property you want to change, ex: Transparency
local Transparency = part.Transparency
part.Touched:connect(function(hit)
if hit.Name~='Water' then return end
part.Transparency= .5
end)
part.TouchEnded:connect(function(hit)
if hit.Name~= 'Water' then return end
part.Transparency= Transparency
end)
the above code will make the part look more transparent if the default Transparency property is 0
Terrain completely skipped my mind. When I think of water I always think of custom parts or mesh deform.