Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Stuck on a script: In need of breathing script. Anyone can help me? [closed]

Asked by 6 years ago

Hello! I am making a roblox game like subnautica, though we are stuck on one thing. I need help with a breathing script, like player can be underwater for 10 sec, after that they get damaged 10 hp each extra second. Anyone knows how to make something like this? Thanks!

0
When players touch the water and 10 seconds have passed, use a while loop to keep doing damage do them and elseif touchended, break the loop Sorukan 240 — 6y
0
Thank you! THough, can it be a water generated by terrain? Or do I need to place a script-block? ( Block that is transparent, cannot collide ) in the water? AddisonAvery 43 — 6y

Closed as Not Constructive by yHasteeD and Zafirua

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
6 years ago

So you can make a touched event for terrain, it will look a little bit like (not writing real lua code because you haven't attempted it yet):

water = 2048 -- the material code for water
int underwater = 0--have it count up for every second under the water

if player touches terrain and terrain's material value is 2048 then
    if underwater > 10 then
        do damage to the player's humanoid
            wait(1)--make it wait a second before checking again
    end
end
Ad