This is the error: 10:10:00.631 - Workspace.Part.Script:21: attempt to get length of local 'weapons' (a userdata value)
I'm making this script for the giggles, but it's supposed to give the player a random weapon once the brick stops spinning and lands on the color red. But it keeps giving me an error please help
randomWeapons = {
game.Lighting.Sword,
game.Lighting.Flamethrower
}
spinningPart = script.Parent
spinningTime = 0.001
clickdetector = Instance.new("ClickDetector",spinningPart)
spinning = false
spinningPart.ClickDetector.MouseClick:connect(function(plr)
if not spinning then
spinning = true
while true do
wait(spinningTime)
spinningPart.CFrame = spinningPart.CFrame *CFrame.Angles(1,0,0)
spinningPart.BrickColor = BrickColor.Random()
if spinningPart.BrickColor == BrickColor.Red() then
print("Giving random weapon")
for _,weapons in pairs(randomWeapons) do
for i = 1,#weapons do
local weaponChosen = weapons(math.random(1,#weapons))
if weaponChosen then
weaponChosen:Clone()
weaponChosen.Parent = plr.Backpack
end
end
end
spinning = false
break
end
end
end
end)
