I am trying to make a randomizing case script that gives the random item to the player.. but it says in the output attempt to index nil with 'Parent' and I dont know what it means
here is the script...
local commoncase = game:WaitForChild("Workspace").CommonCase
local b = script.Parent
b.MouseButton1Click:Connect(function(cases)
if cases.Parent.Humanoid~= nil then
local cash = game.Players:findFirstChild(cases.Parent.Name).leaderstats.Cash
if cash.Value == cash.Value > 100 then
local chi = math.random(1,10)
if chi == 1 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Sabre"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 10 then
local clone = game.Workspace.CommonCase.Epic:WaitForChild("hyper"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 2 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Axe"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 9 then
local clone = game.Workspace.CommonCase.Rare:WaitForChild("ChristmasTreeSword"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 3 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Crowbar"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 8 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Axe2"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 4 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Fife"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 7 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Combat knife"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 5 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Machete"):clone()
clone.Parent = game.Players.LocalPlayer.Backpack
end
if chi == 6 then
local clone = game.Workspace.CommonCase.Common:WaitForChild("Lance")
clone.Parent = game.Players.LocalPlayer.Backpack
end
end
end
end)

4 comments
Which line has the error
line 5
What is "cases"? I figured out the problem, just need to know more before i answer
on line 4 it goes to (function(cases)