A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
naknak
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
Supernapalm
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
m27frogy
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
slayer9365
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
myrco919
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
branefreez
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
ninga95
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
CloneTrooper787
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
raboy117
A Nice Health Pad Vote_lcapA Nice Health Pad Voting_barA Nice Health Pad Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
A Nice Health Pad EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
A Nice Health Pad EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
A Nice Health Pad EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
A Nice Health Pad EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
A Nice Health Pad EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
A Nice Health Pad EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
A Nice Health Pad EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
A Nice Health Pad EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
A Nice Health Pad EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
A Nice Health Pad EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
A Nice Health Pad EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
A Nice Health Pad EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
A Nice Health Pad EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
A Nice Health Pad EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
A Nice Health Pad EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
A Nice Health Pad EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
A Nice Health Pad EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
A Nice Health Pad EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
A Nice Health Pad EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
A Nice Health Pad EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 A Nice Health Pad

Go down 
5 posters
AuthorMessage
Guest
Guest
avatar



A Nice Health Pad Empty
PostSubject: A Nice Health Pad   A Nice Health Pad EmptyAugust 3rd 2010, 2:54 pm

Code:
local heal = 20 --How much it heals
local waiting = 2 --How long before can be used again

local debo = false

function onTouch(hit)
if hit.Parent.Humanoid ~= nil and debo == false then
debo = true
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health + heal
--script.Parent:Remove() --Remove the '--' at the start of the line for one use only
wait(waiting)
debo = false
end
end

script.Parent.Touched:connect(onTouch)
Back to top Go down
Guest
Guest
avatar



A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyAugust 8th 2010, 10:04 pm

Nice job =D
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyAugust 10th 2010, 12:19 am

I think he copied it....
Back to top Go down
Guest
Guest
avatar



A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyAugust 10th 2010, 3:19 pm

But, he added a script to the resources. I never really look at the script anyways xD

Let's make it more efficent, though.

Code:
script.Parent.Touched:connect(function(hit)
wait()
hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove()
end)
Back to top Go down
Guest
Guest
avatar



A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyNovember 29th 2010, 4:21 pm

Its all very good, but what if I program a brick to go over the pad containing the script, it will brake. Just at this into the script to make it a little better.
local hum = hit.Parent:findFirstChild("Humanoid")
if hum~=nil then
[Builderboy202]
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyDecember 15th 2010, 6:38 pm

Code:

script.Parent.Touched:connect(function(hit)
wait()
if hit.Parent:findFirstChild("Humanoid") then
hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove()
end
end
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 18th 2011, 10:19 pm

Code:
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove()
end
end

forgot to put ) at the end of the function
and why do you need a wait() for? its blank
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 18th 2011, 10:19 pm

Code:
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove()
end
end)

ugh
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 18th 2011, 10:21 pm

Sometimes roblox would glitch this. A better way to prevent that would be to add debounce.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 18th 2011, 11:54 pm

Code:
script.Parent.Touched:connect(function(hit)
local deb = false
if deb = false then
    deb = true
    if hit.Parent:findFirstChild("Humanoid") then
          hit.Parent.Humanoid:takeDamage(-20)
          script.Parent:Remove()
    end
deb = false
end)

i dont know why you would need it in this case anyway, your heal pad would just be removed
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 19th 2011, 7:55 pm

Ah. didn't see that. But you broke the script BTW ;)

Code:
if deb == true then
You need two ='s.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 19th 2011, 8:56 pm

nooooo. oh well. we all make mistakes.
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 19th 2011, 8:58 pm

Code:
script.Parent.Touched:connect(function(hit)
local deb = false
if deb == false then
    deb == true
    if hit.Parent:findFirstChild("Humanoid") then
          hit.Parent.Humanoid:takeDamage(-20)
    end
wait(60)
deb = false
end)

i removed :Remove(), debounce would be useless if this wasn't done. also added wait(60)

that's better. i think.
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 19th 2011, 9:56 pm

Last I remember, local isn't needed in RBX.lua.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 19th 2011, 10:42 pm

ah... but this time i have a trick. local is used for optimization (enhancing speed), it is said in lua that you should use local variables as much as possible. it saves more memory usage than using global variables. proof is in the simple script of the widely-used LinkedSword, first made by the admins of roblox. they know more about optimization than me.
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 20th 2011, 6:58 pm

Code:
script.Parent.Touched:connect(function(hit)
pcall(hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove())
end)
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 20th 2011, 7:50 pm

Well, local doesn't determine a variables *** in RBX.lua for some reason. They removed it apparently.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 20th 2011, 9:12 pm

say again? oh and what is pcall()
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 21st 2011, 3:16 am

pcall runs a function in protected mode so it won't crash the script if there is an error in the function.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 27th 2011, 10:32 pm

how does it work? and does it limit the flexibility of the script?
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyJanuary 29th 2011, 7:49 am

you can not use waits in pcall or xpcall.
Back to top Go down
lukenuke75
Novice Scripter
Novice Scripter
lukenuke75


Posts : 38
Join date : 2011-03-07
Age : 27

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyMarch 9th 2011, 12:15 am

wait() is not blank silly :D


its 0.035009250178941



NOTE: i did not know there was a second page :P
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyMarch 10th 2011, 10:12 am

naknak wrote:
Last I remember, local isn't needed in RBX.lua.

It doesn't matter if it is RBX.Lua or Lua, local can be needed. If not needed, it is suggested. Local variables integrate themselves into the environment, making indexing them much faster.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyMarch 10th 2011, 11:32 pm

More typing = faster script

Confusing, much? Oh well, I'll start using local's again and see if I see a difference.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad EmptyMarch 11th 2011, 8:35 pm

oysi ran a test and said that local variables were vaster than normal. ever since i've used local variables many times. XD
Back to top Go down
Sponsored content





A Nice Health Pad Empty
PostSubject: Re: A Nice Health Pad   A Nice Health Pad Empty

Back to top Go down
 
A Nice Health Pad
Back to top 
Page 1 of 1
 Similar topics
-
» How to increase health

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Free Scripts-
Jump to: