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: Simple script doesn't work

Previous Thread :: Next Thread 
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
10 May 2014 04:55 PM
function OnTouch(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local player = game.Players[hit.Parent.Name]
for i = 100, 0, -1 do
wait(0.1)
print(i) -- It goes like 46, then when I walk out of the water, it's 97, 41, 99, 36 etc.
player.PlayerGui.Breath.Hi.Text = i
if player.PlayerGui.Breath.Hi.Text == 0 then
game.Workspace[hit.Parent.Name].Head:Destroy() -- Doesn't kill me
end
end
end
end
game.Workspace.Water.Touched:connect(OnTouch)

function notTouching(hit)
local plyr = game.Players[hit.Parent.Name]
if game.Players:FindFirstChild(hit.Parent.Name) then
plyr.PlayerGui.Breath.Hi.Text = 100 -- The for loop still goes on, this does nothing basiclly.
end
end
game.Workspace.BasePlate1.Touched:connect(notTouching)
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
10 May 2014 05:06 PM
B1
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
10 May 2014 05:14 PM
B2
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 May 2014 05:15 PM
player.PlayerGui.Breath.Hi.Text = i

i is a number value, not a string, use this instead.

player.PlayerGui.Breath.Hi.Text = tostring(i)

If there are other situations like this, fix them using tostring()
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 May 2014 05:17 PM
function OnTouch(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local player = game.Players[hit.Parent.Name]
for i = 100, 0, -1 do
wait(0.1)
print(i)
player.PlayerGui.Breath.Hi.Text = tostring(i)
if player.PlayerGui.Breath.Hi.Text == "0" then
game.Workspace[hit.Parent.Name].Head:Destroy()
end
end
end
end
game.Workspace.Water.Touched:connect(OnTouch)

function notTouching(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local plyr = game.Players[hit.Parent.Name]
plyr.PlayerGui.Breath.Hi.Text = "100"
end
end
game.Workspace.BasePlate1.Touched:connect(notTouching)
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