These functions are not correct and I don’t know how to change it, can anybody help?
You don’t appear to be calling the GiveGadget
and GiveWeapon
functions.
Another thing, you are trying to pass an instance into WaitForChild
, not a string. Try v.Name
instead.
Also are there any errors in the output?
It appears you’re trying to call WaitForChild()
on the strings, not the Gadgets
and Weapons
objects. Add an “s” to those like this.
Gadgets:WaitForChild(v):Clone().Parent = PlayerBackpack
Weapons:WaitForChild(v):Clone().Parent = PlayerBackpack
Also you should be fine with just ‘v’, my apologies.
We’re getting there
Could you show me the following stack and the line of code it mentions?
You don’t do v.Name
, just v
.
This is a bit off-topic, but please use code blocks for better readability
Read the error, please. It is clearly stating that you are passing in a string in ipairs
rather than a table. I see that in some parts of your code, this is true.
Try this:
if typeof(Weapon) == "string" then Weapon = {Weapon} end
for _, weapon in ipairs(Weapon) do
Gadgets:WaitForChild(v):Clone().Parent = PlayerBackpack
end
Here you can see, you are passing strings to the function and then running a for loop looping through a string instead of a table, and thats the reason why it gives that error