I don’t get what it means by “attempt to call a nil value”
it’s printing multiple times because it’s in a for loop
local clone = weapon:FindFirstChild("Handle"):Clone()
I don’t get what it means by “attempt to call a nil value”
it’s printing multiple times because it’s in a for loop
local clone = weapon:FindFirstChild("Handle"):Clone()
Try removing the :Clone() part for now and try to print it.
nil basically means “nothing” in programming. If you have a variable set to nil, it means it doesn’t exist and doesn’t represent anything. When it says “attempt to call a nil value”, that means you are attempting to call a value that does not exist. Either your items are not actually named weapon and Handle, or something else is happening. Could you show existing code?
for i = 1, cells do
local vpf = Instance.new("ViewportFrame")
local weapon
if i ~= weaponCell then
repeat weapon = crates[crateName]:GetChildren()[math.random(#crates[crateName]:GetChildren())]; wait() until weapon:IsA("Accessory")
else
weapon = chosenWeapon
weaponVPF = vpf
end
print(weapon)
if weapon ~= nil then
local clone = weapon:FindFirstChildOfClass("Part")
print(clone.Name)
clone.Parent = vpf
clone.Anchored = true
end
end
some of the ends are cut out, here is most of the code
it printed nil
where’s the line that you put in the first post?
this one, i just changed it but it still didn’t work
well since you checked if weapon is nil or not, we know its not the weapon so the part is nil
Sorry for all the trouble i found out why it was nil. Thank you for your time
np good luck in the future :