How to make Box with 2 items and random on backpack, 1 common 1 rare?

I try make Box of Soda RNG SODA but Idk how to script , i look alot media but don’t have answer i wanted, all i try is look almost same but my script not work
Script:

```local Soda = script.Parent
local prompt = Soda:WaitForChild("ClickDetector")
local ServerStorage = game:GetService("ServerStorage")
local ItemsFolder = ServerStorage:WaitForChild("Soda1in2")
local minTime = 1
local maxTime = 5

local function Give1in2Item(player)
	local items = ItemsFolder:GetChildren()
	if #items > 1 then
		local randomItem = items[math.random(1, #items)]:Clone()
		randomItem.Parent = player.Backpack  -- Give the item to the player's backpack
	end
end

local function handlePrompt()
	prompt.Enabled = false
	wait(math.random(minTime, maxTime))
	prompt.Enabled = true
end

prompt.Triggered:Connect(function(player)
	Give1in2Item(player)
	handlePrompt()
end)

script.Parent.ClickDetector.MouseClick:Connect(Give1in2Item)

Replace this with:

prompt.MouseClick:Connect(function(player)
1 Like

Sorry, I didn’t see the last line of code, just remove the above function.

1 Like

As @supergreendude14 mentioned there is no triggered event for a clickdetector instead its MouseClick event used but if you were looking to use a proximitypronpt then change the clickdetector to a proximityprompt as the object and triggered would work

2 Likes