So i am makeing a spawner part that spawns a random tool from a folder every 5 seconds. the thing is that i dont want the spawner part to have 2 tool in it. The problem is im not sure how to check if there a tool in the spawner part. i have tryed a lots of things like useing FindFirstChild() and things like that but they just dont work can anyone help me?
here my code
local ItemsTable = require(game.Workspace.Spawner.ItemsScript)
local Items = game.ReplicatedStorage.Items:GetChildren()
local SpawnTime = 5
function GetRandomItem()
local Sum = 0
for ItemName,Chance in pairs(ItemsTable) do
Sum += Chance
end
local RandomNumber = math.random(Sum)
for ItemName,Chance in pairs(ItemsTable) do
if RandomNumber <= Chance then
return ItemName
else
RandomNumber -= Chance
end
end
end
while wait(SpawnTime) do
local Item = game.ReplicatedStorage.Items:FindFirstChild(GetRandomItem()):Clone()
Item.Parent = script.Parent
Item.Handle.Position = script.Parent.Position
end
and here a module that has the chances of the items spawning
local module = {
Gun = 15,
Food = 70,
BloxyCola = 70
}
return module
and this is the foulder of all of the items that can spawn
