✓ Accepted answer
Typed all this on mobile so sorry if anything is weird/inaccurate.
If you want to detect when a player is in water or not, you can use the :GetState() function and the HumanoidStateType enum.
Here is a rough example :
local humanoid = somewhereidk
if humanoid:GetState() == Enum.HumanoidStateType.Swimming then
print('Swimming')
end
In this script, the script checks the state of the humanoid. If it’s swimming, it prints “Swimming”, otherwise it does nothing.
Igoralexeymarengobr’s comment can also work too, but you’ll have to put the parts in every single area filled with water. I would prefer my way if you’re planning on only characters to be detected in water. If you want separate parts to be detected though, you’ll probably have to make the invisible parts, or do something else but I don’t know because I can’t test anything at the moment.
Oh, and if you’re trying to check if any player touches the water, you can make a script like my example and put it in StarterCharacterScripts, or get all the players at once and check if they’re in water or not.
Hope this helped!
4 comments
Is TerrainTouched even an event of Workspace? Never seen it in the API.
oh sorry it's suppose to be Terrain.Touched. I was trying stuff like Terrain.Water.Touched just for the heck of it. When I deleted Water, I deleted the "." too.
There is no specific event for touching water. As far as I know, Terrain Touched and TouchEnded don't do anything.
There is no but you can put a invisible part without collision on the water so maybe would work with OnTouched