Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Put Your Item Name inside--
- local ItemTable = {
- 'YourItemName1',
- 'YourItemName2',
- 'YourItemName3',
- 'YourItemName4'
- }
- 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 ItemStorage = RP.ItemStorage
- --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)
Advertisement
Add Comment
Please, Sign In to add comment