Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make player drown after being underwater for (x) amount of time?

So I've been looking for an answer to this for a few hours and i haven't been able to find ANYTHING. I want the player to drown after being under water for (x) amount of seconds. But i don't know how to even get started, or where to put the script.

1 answer

Here's what you can do:

Use a https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged to detect when the player is Swimming.

When they are detected to be swimming, you can start counting down on a timer. When the humanoid's state is changed to something other then swimming, cancel the timer. If the timer reaches 0, you can kill the player.

2 comments

0

where do i put the script?

0

Anywhere. Make sure it's a server script.

This discussion is preserved as it was. New answers, comments, and votes are closed.