generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Why doesn't this work?

Previous Thread :: Next Thread 
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:12 PM
No output errors.

if script.Parent.Parent.Parent.Parent.Character.Head.Position.Y<49 then
wait(1)
script.Parent.Text = "Oxygen: 9/10"
wait(1)
script.Parent.Text = "Oxygen: 8/10"
wait(1)
script.Parent.Text = "Oxygen: 7/10"
wait(1)
script.Parent.Text = "Oxygen: 6/10"
wait(1)
script.Parent.Text = "Oxygen: 5/10"
script.Parent.TextColor3 = Color3.new(170, 0, 0)
wait(1)
script.Parent.Text = "Oxygen: 4/10"
wait(1)
script.Parent.Text = "Oxygen: 3/10"
wait(1)
script.Parent.Text = "Oxygen: 2/10"
wait(1)
script.Parent.Text = "Oxygen: 1/10"
wait(1)
script.Parent.Text = "You have drowned."
script.Parent.Parent.Parent.Parent.Character:BreakJoints()
wait(.9)
script.Parent:remove()
elseif
script.Parent.Parent.Parent.Parent.Character.Head.Position.Y>=49 then
script.Parent.Text = "Oxygen: 10/10"
script.Parent.TextColor3 = Color3.new(0, 0, 0)
end
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:17 PM
b
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:24 PM
b2
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:29 PM
Come on... b3
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
14 Dec 2013 10:31 PM
That will only run once. Try putting it in a while (wait()) do loop.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:31 PM
Okay.
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
14 Dec 2013 10:34 PM
Now, if I go under water, It counts down. I get out and it continues to count down until I die even if I'm on land above Y: 48
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
14 Dec 2013 10:36 PM
use a loop+break
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
14 Dec 2013 10:39 PM
local ox = 10 -- Set oxygen to 10

while (wait(1)) do -- Every 1 second
if (script.Parent.Parent.Parent.Parent.Character.Head.Position.Y<49) then
ox = ox - 1 -- Take 1 away from ox
if (ox <= 5) -- If ox is under or equal to five
script.Parent.TextColor3 = Color3.new(170 / 255, 0, 0)
else
script.Parent.TextColor3 = Color3.new(0, 0, 0)
end
if (ox == 0) then -- If ox is zero
script.Parent.Text = "You have drowned."
script.Parent.Parent.Parent.Parent.Character:BreakJoints()
return -- Just to prevent any errors or mish-mashes
end
end
script.Parent.Text = "Oxygen: "..ox.."/10"
end

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
15 Dec 2013 11:27 AM
How would I make the counter reset back to 10 if they're above or equal to 49?
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
15 Dec 2013 11:37 AM
b
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
15 Dec 2013 11:38 AM
if head.Position >=49 then
yourstuff.Value = 10
or
yourstuff = 10

ect..

-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ --
Report Abuse
Adam2090 is not online. Adam2090
Joined: 19 Jul 2010
Total Posts: 889
15 Dec 2013 12:04 PM
I understand that part, I don't understand how to add it to that loop. I tried it but it just broke the entire thing.
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
15 Dec 2013 12:07 PM
Try this. :3

local ox = 10 -- Set oxygen to 10

while (wait(1)) do -- Every 1 second
if (script.Parent.Parent.Parent.Parent.Character.Head.Position.Y<49) then
ox = ox - 1
else ox = 10
if (ox <= 5) -- If ox is under or equal to five
script.Parent.TextColor3 = Color3.new(170 / 255, 0, 0)
else
script.Parent.TextColor3 = Color3.new(0, 0, 0)
end
if (ox == 0) then -- If ox is zero
script.Parent.Text = "You have drowned."
script.Parent.Parent.Parent.Parent.Character:BreakJoints()
return -- Just to prevent any errors or mish-mashes
end
end
script.Parent.Text = "Oxygen: "..ox.."/10"
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image