A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeFAQRegisterLog 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
 
naknak
 
Supernapalm
 
m27frogy
 
slayer9365
 
myrco919
 
branefreez
 
ninga95
 
CloneTrooper787
 
raboy117
 
Top posting users this month
Latest topics
» Send me an Email
January 8th 2016, 10:14 am by naknak

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
July 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
July 6th 2015, 4:16 pm by m27frogy

» Ambassador!
April 15th 2015, 11:40 pm by naknak

» Boop - Tag
April 13th 2015, 9:46 pm by naknak

» Vip Class Script
April 13th 2015, 4:54 pm by naknak

» Who's active?!
April 13th 2015, 4:52 pm by naknak

» Where to go from here.
April 13th 2015, 4:51 pm by naknak

» Genesis Point
July 17th 2014, 7:04 pm by branefreez

» Reward System
July 17th 2014, 5:41 am by m27frogy

» Script Request
July 10th 2014, 11:43 am by naknak

» local scripts?
July 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
July 10th 2014, 11:36 am by naknak

» Hi. I am new here
April 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
January 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
January 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
January 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
November 26th 2013, 3:33 pm by Keanu73

» Improve Coding
October 26th 2013, 1:12 pm by pook03

» Simple Button
September 1st 2013, 6:19 pm by branefreez


Share | 
 

 A Nice Health Pad

Go down 
AuthorMessage
Guest
Guest



PostSubject: A Nice Health Pad   August 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



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

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

Posts : 878
Join date : 2010-07-30

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

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



PostSubject: Re: A Nice Health Pad   August 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



PostSubject: Re: A Nice Health Pad   November 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
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   December 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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
avatar

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

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

Code:
script.Parent.Touched:connect(function(hit)
pcall(hit.Parent.Humanoid:takeDamage(-20)
script.Parent:Remove())
end)

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   January 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


Posts : 393
Join date : 2011-01-17

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

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

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

PostSubject: Re: A Nice Health Pad   January 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.

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: A Nice Health Pad   January 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
avatar

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

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

you can not use waits in pcall or xpcall.

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
lukenuke75
Novice Scripter
Novice Scripter
avatar

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

PostSubject: Re: A Nice Health Pad   March 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
avatar

Posts : 25
Join date : 2011-03-06
Age : 22

PostSubject: Re: A Nice Health Pad   March 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
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: A Nice Health Pad   March 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
avatar

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

PostSubject: Re: A Nice Health Pad   March 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

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Sponsored content




PostSubject: Re: A Nice Health Pad   

Back to top Go down
 
A Nice Health Pad
Back to top 
Page 1 of 1
 Similar topics
-
» Health 231 >> 197 by a panther, is it normal?
» Has anyone ever been super nice?
» Airbrush Art
» Whats your favourite dessert?
» Favorite exterior condo design?

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