the script works great and im still down to pay. I want to figure out how to change this script a little though. Ill pay200 robux now if you are able to script me a function where instead of spawning the random model into workspace it spawns into 6 of the random drawers in workspace.
this is the script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Http = game:GetService("HttpService")
local remoteEvent = ReplicatedStorage:WaitForChild("ToolClaimEvent")
local lootsFolder = ServerStorage:WaitForChild("Loots")
local function handleLootItems(lootModel: Model)
local claimedOnes = {}
for _,part in lootModel:GetChildren() do
if not part:IsA("BasePart") then continue end
local toolGUID = Http:GenerateGUID()
local detect = Instance.new("ClickDetector")
detect.Parent = part
detect.MaxActivationDistance = 32
detect.MouseClick:Connect(function(player: Player)
local tool = game:GetService("ServerStorage"):WaitForChild("Items"):FindFirstChild(part.Name) -- Checks if theres a tool with the same name as the clicking part
if not tool then return end
local playerBackpack = player:WaitForChild("Backpack")
if not claimedOnes[player.UserId] then claimedOnes[player.UserId] = {} end
if not claimedOnes[player.UserId][toolGUID] then
tool:Clone().Parent = playerBackpack
remoteEvent:FireClient(player,part)
claimedOnes[player.UserId][toolGUID] = true
end
end)
end
end
local function spawnLoots(lootName: string,spawnCFrame)
local existing = lootsFolder:FindFirstChild(lootName)
if not existing then return end
local cloned = existing:Clone()
pcall(function()
if cloned.PrimaryPart and spawnCFrame then
cloned.PrimaryPart.CFrame = spawnCFrame
end
end)
cloned.Parent = workspace:WaitForChild("Loots")
handleLootItems(cloned)
end
local allLoots = {"LootTools1","LootTools2","LootTools3","LootTools4"}
spawnLoots(allLoots[math.random(1,#allLoots)]) -- remove?
while task.wait(15) do
if math.random()>0.75 then
if #lootsFolder:GetChildren()==0 then
spawnLoots(allLoots[math.random(1,#allLoots)])
end
end
end
so what i want basically is for every part in the model that spawns in workspace to teleport to a random drawer there are 6 models and 9 drawers in each.