Problem with loot drop script

so every 1000 seconds script gonna spawn tools in random places and i stuck in the luck math
it does not spawns uncommon and rare heres the script

local spawnLocations = {}
local config = require(script.Droppables.Config)

for _,v in pairs(workspace.Spawns:GetChildren()) do
	if v:IsA("BasePart") then
		table.insert(spawnLocations,v)
	end
end

while task.wait(10) do
	local RandomSpawn = spawnLocations[math.random(1,#spawnLocations)]
	local random = math.random(1,100)
	if random >= config.common then
		for _,loot in pairs(script.Droppables.Common:GetChildren()) do
			if loot:IsA("Tool") then
				loot.Handle.CFrame = RandomSpawn.CFrame
			elseif loot:IsA("Model") then
				loot:PivotTo(RandomSpawn.CFrame)
			end
		end
	elseif random <= 5 then
		for _,loot in pairs(script.Droppables.Legendary:GetChildren()) do
			if loot:IsA("Tool") then
				loot.Handle.CFrame = RandomSpawn.CFrame
			elseif loot:IsA("Model") then
				loot:PivotTo(RandomSpawn.CFrame)
			end
		end
	elseif random >= config.uncommon and random < config.common then
		for _,loot in pairs(script.Droppables.UnCommon:GetChildren()) do
			if loot:IsA("Tool") then
				loot.Handle.CFrame = RandomSpawn.CFrame
			elseif loot:IsA("Model") then
				loot:PivotTo(RandomSpawn.CFrame)
			end
		end
	elseif random >= config.rare and random < config.uncommon then
		for _,loot in pairs(script.Droppables.UnCommon:GetChildren()) do
			if loot:IsA("Tool") then
				loot.Handle.CFrame = RandomSpawn.CFrame
			elseif loot:IsA("Model") then
				loot:PivotTo(RandomSpawn.CFrame)
			end
		end
	end
end

Config Module:

local module = {
	["common"] = 45,
	["uncommon"] = 30,
	["rare"] = 20,
	["legendary"] = 5,
}

return module

Can you provide the error the script is giving upon entry of the script?

1 Like

i just solved it thank you for your reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.