This is all I want to know..
If i say:
script.Parent.Name = "Hello".. math.random(1,100)
then how will i use :FindFirstChild to get the random number?
example:
local count = math.random(1,100) local objectOne = Instance.new("IntValue",workspace) local objectOne.Value = "Brick"..count count=count + math.random(1,100) local objectTwo = Instance.new("IntValue",workspace) objectTwo.Value = "Brick"..count
then in another script
print(workspace:FindFirstChild("Brick"..math.random))
How would this work?
There are a couple strategies you can use:
You could have a ModuleScript whose sole purpose is to return a table that other scripts can share:
--Module script (let's call it "List" and put it in ServerScriptService) return {} --Script that does renaming script.Parent.Name = "Hello".. math.random(1,100) local list = require(game.ServerScriptService.List) table.insert(list, script.Parent) --Script that wants the list of items: local list = require(game.ServerScriptService.List) --do whatever you want to 'list'. Note that you cannot say "list = {}", but you can manually delete all the entries, if needed. ex: local obj for i = 1, #list do obj = list[i] --deal with obj here list[i] = nil -- remove the object from the list so we don't deal with it ever again in the future. We mustn't use table.remove or else that'll mess up the rest of the for loop. end
http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#Patterns
Number = ("Brick" .. count):match("%d+") --returns the count