Delete script not work, help

bro. it’s does not work :pensive:

Maybe this is due to the fact that I have a local script instead of tool?

Share the entire roblox studio file

I hope I did everything right :smile:

1 Like

fileroblox.rbxl (118.4 KB)

local CD = script.Parent
local Label = CD.Parent.BillboardGui.TextLabel

local RP =  game:GetService('ReplicatedStorage')
local ItemFolder = RP.ItemFolder


local OldItem = nil
local function onClicked(player)
	if OldItem ~= nil then
		OldItem:Destroy()
	end
	local ChosenItem = Label.Text
	wait(0.5)
	print(ChosenItem)
	Label.Text = 'You got '.. ChosenItem
	local item = ItemFolder:FindFirstChild(ChosenItem)
	if item then
		item.Parent = player.Backpack
		OldItem = item
	end
end


local ItemTable = {
	'Electro',
	'Electro',
	'SunGodPowers',
	'SunGodPowers'
}

local Dbg = true
local ScrollTime = 2
local ScrollInterval = 0.01
local ScrollSound = "rbxassetid://421058925"
local FinishSound = "rbxassetid://4525871712"
local OldItem = nil
script.Parent.MouseClick:Connect(function(Player)
	if Dbg then
		Dbg = false
		for i = 1,(ScrollTime/ScrollInterval) do
			if ScrollSound ~= "" then
				local Sound = Instance.new("Sound", script.Parent)
				Sound.Volume = 0.25
				Sound.SoundId = ScrollSound
				Sound:Play()
				game:GetService("Debris"):AddItem(Sound, Sound.TimeLength)
			end
			wait(ScrollInterval)
			local ItemDisplay = ItemTable[math.random(1,#ItemTable)]
			Label.Text = ItemDisplay
		end
		if FinishSound ~= "" then
			local Sound = Instance.new("Sound", script.Parent)
			Sound.Volume = 0.25
			Sound.SoundId = FinishSound
			Sound:Play()
			game:GetService("Debris"):AddItem(Sound, Sound.TimeLength)
		end
		local NewItem = ItemFolder:FindFirstChild(Label.Text)
		if NewItem ~= nil then
			local NewItemClone = ItemFolder:FindFirstChild(Label.Text):Clone()
			if OldItem ~= nil then
				OldItem:Destroy()
			end
			OldItem = NewItemClone
			NewItemClone.Parent = Player.Backpack
		end
		Dbg = true
	end
end)
1 Like

thank you for spending your time with me :grin:

it helped me :grin: :grin: :clap:t2: