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: Random Pick Help

Previous Thread :: Next Thread 
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 04:50 AM
Heres my script:

debounce = false
function onTouched()
local h=script.Parent:findFirstChild("Humanoid")
if h~=nil then
debounce = true
local parts = game.Workspace.StarterGui.Fence:GetChildren()
for i=0, #parts do
local c=game.Workspace.StarterGui.Fence:GetChildren()
b=c[math.random(1,#c)]
local copy=b:Clone()
copy.Parent=script.Parent.Parent
wait(1)
end
debounce=false
end
end

script.Parent.Touched:connect(onTouched)

It should pick randomly a part out of Fence and clone it. But if i touch the button nothing happens. Output doesnt give any error.
Report Abuse
itunes89 is not online. itunes89
Joined: 19 Jan 2011
Total Posts: 1957
20 Jul 2012 05:07 AM
Dude make debounce local.


local debounce = false
function onTouched(p)
local h=p..Parent:findFirstChild("Humanoid")
if h~=nil then
debounce = true
local parts = game.Workspace.StarterGui.Fence:GetChildren()
for i=0, #parts do
local c=game.Workspace.StarterGui.Fence:GetChildren()
b=c[math.random(1,#c)]
local copy=b:Clone()
copy.Parent=script.Parent.Parent
wait(1)
end
debounce=false
end
end
Report Abuse
itunes89 is not online. itunes89
Joined: 19 Jan 2011
Total Posts: 1957
20 Jul 2012 05:08 AM
local debounce = false
function onTouched(p)
local h=p.Parent:findFirstChild("Humanoid")
if h~=nil then
debounce = true
local parts = game.Workspace.StarterGui.Fence:GetChildren()
for i=0, #parts do
local c=game.Workspace.StarterGui.Fence:GetChildren()
b=c[math.random(1,#c)]
local copy=b:Clone()
copy.Parent=script.Parent.Parent
wait(1)
end
debounce=false
end
end

Sry added a extra dot.
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 05:37 AM
thx man :) but now i got a new problem, parts will be double copied -.- i will whink aboout it myself.
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
20 Jul 2012 05:40 AM
workspace.StarterGui ?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 05:40 AM
Ok, im i right if i say local c is a table ?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 06:16 AM
New Qustion. If i have a Model with 5 Blocks in it. Can i fill them into a Table and also remove them from it?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 07:03 AM
Bump
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 07:54 AM
can somebody help me !?
Report Abuse
Nathanjustrocks is not online. Nathanjustrocks
Joined: 06 May 2012
Total Posts: 626
20 Jul 2012 08:16 AM
Make it local.
Report Abuse
Nathanjustrocks is not online. Nathanjustrocks
Joined: 06 May 2012
Total Posts: 626
20 Jul 2012 08:16 AM
Yes, you can, I think.
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 10:23 AM
But could somebody show me how or give me some information what i should search in the wiki ?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 10:40 AM
debounce = false
function onTouched(hit)
if hit.Parent ~= nil then
local h=hit.Parent:findFirstChild("Humanoid")
if h~=nil and debounce == false then
debounce = true
local parts = game.Lighting.Tycoon1.Fence:GetChildren()
for i=0, #parts do
part=parts[math.random(1,#parts)]
local copy=part:Clone()
copy.Parent=script.Parent.Parent

table.remove(parts,b)
wait(1)
end
end
debounce=false
end
end

script.Parent.Touched:connect(onTouched)

Guys thats what i have now. But why does it still double clone parts? I mean now it should take b out of the Array parts. but it seems like it doesnt :(
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 10:50 AM
And it also can be activated twice -.-
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 10:51 AM
I mean debounce isnt working. somehow.
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
20 Jul 2012 10:57 AM
bump
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