storage = game.ReplicatedStorage:GetChildren() backpack = game.Players.LocalPlayer.Backpack math.randomseed(tick()) storage["Kagune" .. tostring(math.random(8))]:clone().Parent = backpack
I have 8 Different local scripts in Replicated storage this script should put a random 1 in my backpack when I enter the game but it doesnt.
This is in a local script in StarterPack and the 8 local scripts I have are:
Kagune1 Kagune2 Kagune3 Kagune4 Kagune5 Kagune6 Kagune7 Kagune8
There are other things in Replicated Storage such as models.
"storage" is a list of children, but you're indexing it with a string key (the name of the script). Get rid of the ":GetChildren()" part on the first line and it should work.
you have to put 2 arguments into math.random()
.
So if you want 1-8, you would do
math.random(1,8)
so for your code it would become:
storage = game.ReplicatedStorage:GetChildren() backpack = game.Players.LocalPlayer.Backpack math.randomseed(tick()) local kaguneClone = storage["Kagune" .. tostring(math.random(1,8))]:Clone() kaguneClone.Parent = backpack
I changed the cloning line so it would be easier to read^^