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: Making a button work once?

Previous Thread :: Next Thread 
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
08 Jan 2012 11:51 PM
function onTouch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) then
print 'lol!'
end
end

script.Parent.Touched:connect(onTouch)

How would you make this script work only once, so it wouldnt spam the output with lol!lol!lol!lol! Ive seen debounce, is that it? If it is, how do i use it?
Report Abuse
callofrobloxiamw3 is not online. callofrobloxiamw3
Joined: 28 May 2011
Total Posts: 488
09 Jan 2012 12:06 AM
if you want it to remove after using:

function onTouch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) then
print 'lol!'
script.Parent:Remove()
end
end

script.Parent.Touched:connect(onTouch)

if you dont want it to remove after using:

node = 0

function onTouch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) and node == 0 then
print 'lol!'
node = 1
end
end

script.Parent.Touched:connect(onTouch)



Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
09 Jan 2012 12:36 AM
Replace


script.Parent.Touched:connect(onTouch)

with

x = script.Parent.Touched:connect(onTouch)


then, when you don't want it to work anymore, you can do

x:disconnect()
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
09 Jan 2012 01:11 AM
I should have worded it better, i wanted it so it only worked once per player.
Report Abuse
GuildsRPG is not online. GuildsRPG
Joined: 06 Aug 2011
Total Posts: 24
09 Jan 2012 01:20 AM
function onTouch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) and if humanoid.Parent.Value == nil then
v = instance.new(Value, humanoid)
print 'lol!'
end
end

script.Parent.Touched:connect(onTouch)

Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
09 Jan 2012 04:00 AM
Guilds, your doesnt seem to work :/
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