Is it possible to make a breath meter whenever u go into Terrain's water not with a part or block but the generated one and when ur inside is it possible to make a breath meter with a gui ? whenever u run out of u start losing health ?
Breath meter ?
1 answer
hmm ..using this value detection isnt the best for a breathe script cause when the player floats in water with his head still being above the water surface then he will still lose breath ...
i woulds suggest something complex ...i would make a morph into the spawn point which welds a small part under the players mouth and call it "b" for breath .
Now i would place a invisible part inside the whole water which contains a script which sets a value to true as long as the part "b" is touching it . (dont worry ill post these two scripts under this text wall ^^)
now we need an starter gui ..idk on how to make it animated ..but i know the rest a bit .. so this gui ..lets call it breathmeter contains a number value called "breath" and set it to 100
Now "->AS long<-" as the part "b" inside players head is touching the water part
->The script inside the water part will search inside the playergui for the breathmeter and inside it for the breath value and lower it by -1 each 0.5 of wait time . and once it reached 0 it will stop lowering it
...well sadly i dont know how to script this part ..i often tried similar things but always failed ):
now once the breathe value reaches 0 the player will get like like 1 damage after each 1 second of wait time ->but only if the breathe value is is smaller than 1 once the value is bigger than 1 the damage script part will stop .
sorry for the long text now ill post the morph and the while touching script((but without detection of the b part sorry ))
function Touched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
script.Parent.Grounded.Value = true ---get sure a value named :Grounded is inside the part
end
function TouchEnd()
script.Parent.Grounded.Value = false
end
script.Parent.Touched:connect(Touched)
script.Parent.TouchEnded:connect(TouchEnd)
Now the script which welds the b part onto players head ..ya can also use a hat which contains the part called "b"
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Head") == nil then
local g = script.Parent.Parent.Head:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Head
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
if h[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
script.Parent.Touched:connect(onTouched)
^ ^ ^ ^ ^ place this script into your spawn location/spawn point then place a model called Head into your spawn location and place the "b part inside this model ..make sure the b part is anchored and invisible .
About the other scripts ..well ya will need many script parts which contains many funtions that check if a local script value are true or false ..i cant help ya any better sorry i have no time left for further explanations and thoughts...
2 comments
sir, atleast you tried thank you !
well i hope it helps atleast a bit
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Go by the Swimming State for Humanoid
waaat ?...
We are not a request site, but we can give you the event for if a person is swimming http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Swimming The swimming event will provide a value, whenever that value is greater than 0 then the user is swimming. You can do something like if val > 0 then swim = true else swim = false end