10:03:57.795 - Players.Player1.PlayerGui.ScreenGui.LocalScript:86: attempt to index local 'm' (a nil value)

10:04:40.041 - Players.Player1.PlayerGui.ScreenGui.LocalScript:37: bad argument #2 to 'random' (interval is empty)

10:04:35.232 - Players.Player1.PlayerGui.ScreenGui.LocalScript:46: attempt to index local 'm' (a nil value)

local choose = script.Parent.Choose
local button = choose.ButtonSpin
local claim = choose.ButtonKeep

function displayHINT(string, parent, time)
	local msg = choose.Spin.TextLabel
	
	msg.Text = string
	if time ~= nil then
	wait(time)
	
	end
	end
gear = {}

local mm = game.Lighting.Choices:GetChildren()
for i=1,#mm do
	if mm[i].className == "HopperBin" and mm[i]:findFirstChild("PickMe") == nil then
		table.insert(gear,mm[i])
		end
	end

function choosegear()
	local	mm = game.Lighting.Choices:GetChildren()
		for i=1,#mm do
			if mm[i].className == "Model" and mm[i]:findFirstChild("PickMe") == nil then
				table.insert(gear,mm[i])
				end
			end


	button.MouseButton1Up:connect (function()
		if choose.Folder.Trys.Value >= 1 then
		choose.Folder.Trys.Value = choose.Folder.Trys.Value - 1
		local randommultiplier = math.random(80,100)
		local t = .01
		local pick = math.random(1,#gear)
		local times = 0
		while true do 
			
			if pick > #gear then
				pick = 1
				end

			local m = (gear[pick]) 
			displayHINT("" .. m.Name .. "", game.Workspace, t)
			times = times + 1

			if times > 15 then
				t = t*2
				times = 0
				end

			randommultiplier = randommultiplier - 1

			if randommultiplier < 1 then 
			print(gear[pick].Name .. ", " .. m.Name)
			
			table.remove(gear, pick)
			--return m 
			choose.Folder.Enable.Value = true
			end

			pick = pick + 1

			
		end
		end
	end)
	end
	


claim.MouseButton1Up:connect (function()
	if choose.Folder.Enable.Value == true then
	local a = game.Lighting:FindFirstChild(choose.Spin.TextLabel.Text, true)
	a:Clone().Parent = script.Parent.Parent.Parent.StarterGear
	a:Clone().Parent = script.Parent.Parent.Parent.Backpack
	choose.Folder.Enable.Value = false
	end
end)

while true do
	wait(0.1)
		local m = choosegear()
		displayHINT("" .. m.Name .. "", game.Workspace, .8) 
end

2 comments

0

You didn't even return anything with the 'choosegear' function. Additionally, when 'math.random(1,#gear)' is being called; the number of items in gear is '0', which means you're trying to choose a randomValue in the max parameter that is lower than the min parameter. Since choosegear() refers to nothing [nothing is returned] that is why 'm' is being 'nil' at the moment.

0

still couldnt fix these errors.....