I need help because when I click spin I get two "quirks", let's call them a quirk, the new quirk doesn't replace the old one, is there any method to make the previous quirk be replaced? If you need the script, I'll put what clones the quirk in the player's backpack.
local classes = game.ServerStorage.Classes script.Parent.SpinEvent.OnServerEvent:Connect(function(plr, item, rarity) local class = classes:FindFirstChild(item) if class then local cloned = class:Clone() cloned.Parent = plr.Backpack end end)
have the local script that make i get the class
local plr = game.Players.LocalPlayer local cooldown = 3 local debounce = false local defaultbackroundcolour = script.Parent.Parent.Result.BackgroundColor3 local backround = { {Rarity = "Common", Colour = Color3.fromRGB(255, 255, 255)}, {Rarity = "Rare", Colour = Color3.fromRGB(0, 255, 0)}, {Rarity = "Epic", Colour = Color3.fromRGB(126, 31, 185)}, {Rarity = "Legendary", Colour = Color3.fromRGB(255, 255, 0)}, } local item = { {Name = "OFA", Rarity = "Legendary"}, {Name = "Ice", Rarity = "Rare"}, {Name = "HHHC", Rarity = "Epic"}, {Name = "Fire", Rarity = "Common"}, } local lootTable1 = { {Item = item[1], Weight = 5}, {Item = item[2], Weight = 37}, {Item = item[3], Weight = 12}, {Item = item[4], Weight = 0}, } local function returnSumOfWeight(lootTable1) local sum = 0 for i, entry in ipairs(lootTable1) do sum = sum + entry.Weight end return sum end local function getRandomItem(lootTable1) local randomNumber = math.random(returnSumOfWeight(lootTable1)) for i, entry in ipairs(lootTable1) do if randomNumber <= entry.Weight then return entry.Item else randomNumber = randomNumber - entry.Weight end end end script.Parent.MouseButton1Click:Connect(function() if debounce == false then debounce = true for count = 1, 30 do local item = getRandomItem(lootTable1) script.Parent.Parent.Result.Text = item.Name wait(.05) end local item = getRandomItem(lootTable1) local name = item.Name local rarity = item.Rarity script.Parent.SpinEvent:FireServer(name, rarity) script.Parent.Parent.Result.Text = name for i, v in ipairs(backround) do if v.Rarity == rarity then script.Parent.Parent.Result.BackgroundColor3 = v.Colour end end wait(cooldown) script.Parent.Parent.Result.Text = "" script.Parent.Parent.Result.BackgroundColor3 = defaultbackroundcolour debounce = false end end)