[HELP] I need to be able to detect if a player is in water

I am currently writing a script and part of said script requires the player to be in water so it shows ox_lib’s prompt. Any ideas?

Have you tried IsEntityInWater on the player ped?

1 Like

How would I make that work though. Sorry, im extremely new to fivem coding and coding in general :grin:

if IsEntityInWater(PlayerPedId()) then
    print("Hello I'm in the water")
end

I’m unsure though what that native exactly considers ‘in water’.

1 Like


Im getting this error when I attempt to use that

From the name of your file it seems you’re trying to call it server side, this is a client sided native

I added it to the client script. However when I go underwater/in water it doesnt actually print anything or do something.

You need to call it every frame or so i believe

put it in a thread with a wait of 0 or 1

2 Likes