Need help with a script

image

I do not know what it means by 3. Please help, the script is supposed to select a random weapon from the primaries folder and give it to the player.

Instead of v it should be v:GetChildren().

image

image

and primary variable does getchildren

It also does select a random weapon, but the error doesn’t make sense i dont know what the “3” comes from.

This isn’t the problem with the variable. The problem is the v variable. It should be primary[math.random(1, #primary)]:Clone() instead.

replace the for i thing with this

for i = 1, #primary:GetChildren()

v variable? what do u mean -------------

v is a variable. You are indexing v with a random child of primary, but it appears that does not exist. You should replace v with primary.

I’m also not sure what the point of this is, as you are cloning every primary.

I thought I only cloned one? I selected one of them using math.random

read my message above

it will loop per how many objects are in the primary

This is true, but you are indexing v which is the problem.

I have difficulty communicating to beginners, so I’ll leave it to others.

I’ll try it and see if it will work

image

is this what u meant

edit the one in the math random brackets to #primary:GetChildren() as well

but wouldn’t I be getting the children 3 times

image
thats 2

image

thats 3

well make sure to note what’s the variable next time, you can remove the :GetChildren() on each one i asked to add on

It gives me all the tools in primary

That’s because you put it in a loop which is unnecessary.

I was told to do that ------------