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: This script is broken.

Previous Thread :: Next Thread 
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
04 Oct 2014 07:13 PM
There is apparently an error at the second parenthesis behind (m:GetChildren))]. I've tried fixing it myself but it won't work. Help?

function reduce(t)
local ret = {}
local i = 1
for _,v in pairs(t) do
if v:IsA("Tool") then
ret[i] = v
i = i+1
end
return ret
end

m = script.Parent -- assumes script parent is the model
m.ClickDetector.Mouse1Clicked(function() -- I don't actually know the clicked event for clickdetectors
reduce(m:GetChildren())[math.random(1, #reduce(m:GetChildren))]:Clone()
end)
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
04 Oct 2014 07:27 PM
you are doing :GetChildren))

obviously, it SHOULD be :GetChildren()
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
04 Oct 2014 07:35 PM
Now its saying the ] after it is invalid too.
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
04 Oct 2014 07:39 PM
m = script.Parent
m.ClickDetector.MouseClick:connect(function()
reduce(m:GetChildren()[math.random(1, #reduce(m:GetChildren())]:Clone()
end)
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
04 Oct 2014 07:39 PM
reduce(m:GetChildren())[math.random(1, #reduce(m:GetChildren()))]:Clone()

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