this is a localscript located inside a textbutton.

the local script is supposed to activate when the button is pressed, however i've run into an error that says bad argument. (LINE 11) but I don't see any errors.

button = script.Parent
player = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
	
local menu = player.PlayerGui:WaitForChild("Menu")
menu.MainFrame:TweenPosition(UDim2.new(-2, 0, 0, 0),"Out", "Quart", 2)
local mapstorage = game.Workspace.mapStorage
	
local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren()
	local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
	chosenmap:Clone().Parent = mapstorage
	local spawns = chosenmap:WaitForChild("Spawns"):GetChildren()
	local allspawns = math.random(1, #spawns)
	local randomspawn = spawns[allspawns]
	
	if #spawns > 0 then
	
	player.Character.HumanoidRootPart.CFrame = CFrame.new(spawns, math.random)
	
	local pistol = game.ReplicatedStorage.Weapons.Pistol
	local cPistol = pistol:Clone()
	cPistol.Parent = player.Backpack
			
	local sledge = game.ReplicatedStorage.Utility.Sledge
	local cSledge = sledge:Clone()
	cSledge.Parent = player.Backpack
	
	end
end)