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: Need Help With Regen Script

Previous Thread :: Next Thread 
Clearest is not online. Clearest
Joined: 19 Jun 2011
Total Posts: 1166
22 Dec 2013 08:18 PM
I am trying to use this script, but I would like it to be disabled after the button is hit for 10 seconds rather than the color just changing. Can you guys help? Here's the script.

local box = script.Parent


local debounce = false


local everything = {model}
local names = {model}

local children = game.Workspace:children()
for i=1,#children do
if (children[i].Name == "waterboat") then -- Replace your model here with the name of your model (the name that appears in the explorer)
table.insert(everything, children[i]:clone())
table.insert(names, children[i].Name)
end
end


function regen()
for i=1,#everything do
game.Workspace:findFirstChild(names[i]):remove()
new_thing = everything[i]:clone()
new_thing.Parent = game.Workspace
new_thing:makeJoints()
end
end

function onTouched()
script.Parent.BrickColor = BrickColor.new(26)

regen()
wait(10)


script.Parent.BrickColor = BrickColor.new(104)


debounce = false
end

script.Parent.ClickDetector.MouseClick:connect(onTouched)
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
22 Dec 2013 08:22 PM
local box = script.Parent
local debounce = false
local everything = {model}
local names = {model}
local children = game.Workspace:children()

for i=1,#children do
if (children[i].Name == "waterboat") then -- Replace your model here with the name of your model (the name that appears in the explorer)
table.insert(everything, children[i]:clone())
table.insert(names, children[i].Name)
end
end

db = false
function regen()
if db = false then
db = true
for i=1,#everything do
game.Workspace:findFirstChild(names[i]):remove()
new_thing = everything[i]:clone()
new_thing.Parent = game.Workspace
new_thing:makeJoints()
wait(10)
db = false
end
end
end

function onTouched()
script.Parent.BrickColor = BrickColor.new(26)

regen()
wait(10)

script.Parent.BrickColor = BrickColor.new(104)

debounce = false
end

script.Parent.ClickDetector.MouseClick:connect(onTouched)
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
22 Dec 2013 08:23 PM
^Dont know if that'll be in sync with the color changing...
Report Abuse
Clearest is not online. Clearest
Joined: 19 Jun 2011
Total Posts: 1166
22 Dec 2013 10:48 PM
I can't get it to work at all using the script you provided. Studio shows a error on the line "if db = false then". Thank you for trying to help me.
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
22 Dec 2013 10:59 PM
local box = script.Parent
local debounce = false
local everything = {model}
local names = {model}
local children = game.Workspace:children()

for i=1,#children do
if (children[i].Name == "waterboat") then -- Replace your model here with the name of your model (the name that appears in the explorer)
table.insert(everything, children[i]:clone())
table.insert(names, children[i].Name)
end
end

db = false
function regen()
if db == false then
db = true
for i=1,#everything do
game.Workspace:findFirstChild(names[i]):remove()
new_thing = everything[i]:clone()
new_thing.Parent = game.Workspace
new_thing:makeJoints()
wait(10)
db = false
end
end
end

function onTouched()
script.Parent.BrickColor = BrickColor.new(26)

regen()
wait(10)

script.Parent.BrickColor = BrickColor.new(104)

debounce = false
end

script.Parent.ClickDetector.MouseClick:connect(onTouched)


--sorry, i forgot about the other equal, this should work now?
Report Abuse
Clearest is not online. Clearest
Joined: 19 Jun 2011
Total Posts: 1166
22 Dec 2013 11:19 PM
Thanks! It works great!
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
22 Dec 2013 11:34 PM
No prob.
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