Hello everyone. :волна:
How do I make the old item disappear in Roblox Studio when opening the next case? Tell pls :молиться:
'ItemName',
'ItemName',
'ItemName',
'ItemName'
}
local CD = script.Parent.ClickDetector
local Label = script.Parent.BillboardGui.TextLabel
--Debounce Mechanism--
local Debounce = false
local Stop = false
--Put your Item inside a folder in Replicated Storage--
local RP = game:GetService('ReplicatedStorage')
local ItemFolder = RP.ItemFolder
--Click Function--
local function onClicked(player)
--Checking--
print('Clicked')
--if debounce = true--
if Debounce then print('Debounce Active') return end
Debounce = true
--Stop = true if the function is running--
spawn(function()
wait(5)
Stop = true
end)
math.randomseed(tick())
--choosing 1 item every 0.1 seconds until stop = true--
repeat
local ItemDisplay = ItemTable[math.random(1,#ItemTable)]
Label.Text = ItemDisplay
wait(0.1)
until Stop == true
--chosen item result--
local ChosenItem = Label.Text
wait(0.5)
print(ChosenItem)
Label.Text = 'You got '.. ChosenItem
--finding the item in the folder--
if ItemFolder:FindFirstChild(ChosenItem) then
local cloned = ItemFolder[ChosenItem]:Clone()
cloned.Parent = player.Backpack
end
--stop the debounce--
Stop = false
wait(1)
Debounce = false
end
--Run the function when you left click--
CD.MouseClick:Connect(onClicked)