RNG game bug with equipping (TextButton)

Use more in depth debug statements

equipButton.MouseButton1Click:Connect(function()
    print("Auras Value: " .. tostring(invFrame.Parent.Storage.Auras.Value))
    print("Max Value: " .. tostring(invFrame.Parent.Storage.Max.Value))
    print("equippedAnAura: " .. tostring(equippedAnAura))
    print("equipWarned: " .. tostring(equipWarned))
    print("showedEquipWarning: " .. tostring(showedEquipWarning))
    -- rest of your code
end)

Looking at it now, It looks like you handling your values on the client, this can create serious security risks and could you make sure you are updating this value on the server as well invFrame.Parent.Storage.Auras.Value? Then remove it from the client as the server will replicate it to the client.

ill use more in depth debug statements, you want me to update the aruasvalue (intvalue) on the server aswell? (its inside of a gui)

Wait shouldn’t it have two if statements

Yes update any values that you are doing on the client on the server then remove them from the client. It’s good to store these values on the server because it adds an extra layer of security not a strong one but better than giving the client blown out access to manipulate it easily.

If you want to make it easy you could pass through the instance with the remote event just for testing then refactor it later.

local data = {
 Auras = invFrame.Parent.Storage.Auras,
 MaxValue = invFrame.Parent.Storage.Max
}

remoteEvent:FireServer(result, data)

This is a quick way of doing it

what do you mean (what would the second if statement have), ive already done every possibility i need to warn and equip an aura

Try this:


local equippedAnAura = false
	local equipWarned = false
	local showedEquipWarning = false
	
	skipButton.MouseButton1Click:Once(function()
		local warned = false
		if chance > specialChance then
			blackFrame.Warning.Visible = true
			warned = true
                end
		if warned == true then
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false

			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		else
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		end
	end)

`

How come the code is also copied… if warned then CODE else SAME CODE end? Just a question they both do the same thing if warned it true or false it does the same exact code.

they do the same thing to warn the player so if they click again, its because they didnt want that aura, even though it warned them:

  • player clicks the button
  • if the aura has a big enough chance it shows the warning
  • if the player clicks again then the aura gets skipped, if they click the equip button insted, it equips the aura

changing the values to the server doesnt change anything, but its more secure now atleast, ive also tried looking at more debugging values, its all working good

having another if statement also doesnt work, sorry

Okay so just to be clear after a while of playing your game your equipButton stops working randomly, but continues to print the values, This means that the connection is still tied which is good. Now we know one of the if statements are not being met. Could you figure out which if statement is not being met so we can narrow down this issue more?

no, its when an aura is skipped, as i told you before, then it stops working.
As for the if statement, i think its the first one, the one that has the “Equip:” result shows twice in the output

ill show you:

  • first i rolled a common
  • i skipped this common
  • then i rolled an uncommon
  • i equipped this uncommon
  • the auras that got inside of my inventory where both uncommon and common in that order:
    (when you skip an aura, that aura doesnt get printed into the output)

image

this is the full script

local rp = game:GetService("ReplicatedStorage")
local ss = game:GetService("SoundService")
local equipEvent = rp.EquipAura
local rollEvent = rp.Roll
local mainEvent = rp.MainEvent
local button = script.Parent
local Auras = require(rp:WaitForChild("Auras"))

local invFrame = script.Parent.Parent.Parent:WaitForChild("Tabs").Inventory:WaitForChild("ScrollingFrame")
local collectionFrame = script.Parent.Parent.Parent:WaitForChild("Tabs").Collection:WaitForChild("ScrollingFrame")
local exampleBtn = invFrame:WaitForChild("Example")

local db = false

local specialChance = 1000
local cutsceneChance = 10000

local function auraTick(nameTxt : TextLabel, chanceTxt : TextLabel)
	local selectedAura = math.random(1, #Auras)
	
	local aura = Auras[selectedAura]
	
	nameTxt.Text = tostring(aura.name)
	nameTxt.Position = UDim2.fromScale(.5, .46)
	nameTxt.TextColor3 = aura.color
	nameTxt.FontFace = aura.font
	game.TweenService:Create(nameTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), { Position = UDim2.fromScale(.5, .48)}):Play()
	
	chanceTxt.Text = "1 in " .. tostring(aura.chance)
	chanceTxt.Position = UDim2.fromScale(.5, .515)
	chanceTxt.TextColor3 = aura.color
	chanceTxt.FontFace = aura.font
	game.TweenService:Create(chanceTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), { Position = UDim2.fromScale(.5, .535)}):Play()
	
	ss:WaitForChild("Tick"):Play()
end

button.MouseButton1Click:Connect(function()
	if db == false and game.Players.LocalPlayer:GetAttribute("AutoRoll") == false then
		db = true
		
		rollEvent:FireServer()
	end	
end)

rollEvent.OnClientEvent:Connect(function(result, chance, color, font)
	local blackFrame = script.Parent.Parent.Frame
	local star = blackFrame.Star
	local vignette = blackFrame.Vignette
	
	local nameTxt = blackFrame.AuraName
	local chanceTxt = blackFrame.AuraChance
	
	local skipButton = blackFrame.SkipAura
	local equipButton = blackFrame.EquipAura
	
	local skipClicked = false
	local equipClicked = false
	
	local cooldown = game.Players.LocalPlayer:GetAttribute("Cooldown")
	
	blackFrame.Visible = true
	
	auraTick(blackFrame.AuraName, blackFrame.AuraChance)
	task.wait(cooldown - 0.25)
	auraTick(blackFrame.AuraName, blackFrame.AuraChance)
	task.wait(cooldown - 0.25)
	auraTick(blackFrame.AuraName, blackFrame.AuraChance)
	task.wait(cooldown - 0.25)
	auraTick(blackFrame.AuraName, blackFrame.AuraChance)
	task.wait(cooldown - 0.25)
	
	nameTxt.Text = tostring(result)
	nameTxt.Position = UDim2.fromScale(.5, .46)
	nameTxt.TextColor3 = color
	nameTxt.FontFace = font
	game.TweenService:Create(nameTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), { Position = UDim2.fromScale(.5, .48)}):Play()

	chanceTxt.Text = "1 in " .. tostring(chance)
	chanceTxt.Position = UDim2.fromScale(.5, .515)
	chanceTxt.TextColor3 = color
	chanceTxt.FontFace = font
	game.TweenService:Create(chanceTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), { Position = UDim2.fromScale(.5, .535)}):Play()

	ss:WaitForChild("Tick"):Play()
	task.wait(cooldown - 0.25)
	
	if chance >= specialChance and chance < cutsceneChance then
		blackFrame.Transparency = 0
		vignette.Visible = true
		vignette.ImageTransparency = 1
		vignette.ImageColor3 = color
		
		game:GetService("TweenService"):Create(vignette, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.In), { ImageTransparency = 0 }):Play()
		
		task.wait(4)
		ss:WaitForChild("NormalBoom"):Play()
		
		blackFrame.Transparency = 0.45
		vignette.ImageColor3 = Color3.fromRGB(255, 255, 255)
		vignette.ImageTransparency = 1
	elseif chance >= cutsceneChance then
		ss:WaitForChild("Shine"):Play()
		
		blackFrame.Transparency = 0
		star.Visible = true
		vignette.Visible = true
		
		star.ImageColor3 = color
		vignette.ImageColor3 = color
		vignette.ImageTransparency = 0
			
		star:TweenSize(UDim2.fromScale(0.5, 0.5), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 4)
		game:GetService("TweenService"):Create(star, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), { Rotation = math.random(360, 360*1.5) }):Play()
		task.wait(4)
		star:TweenSize(UDim2.fromScale(1, 1), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 4)
		task.wait(4)
		
		ss:WaitForChild("SpecialBoom"):Play()
		blackFrame.Transparency = 0.45
		vignette.Visible = false
		vignette.ImageColor3 = Color3.fromRGB(255, 255, 255)
		vignette.ImageTransparency = 1
		star.Visible = false
		star.Size = UDim2.fromScale(1, 1)
		star.Rotation = 0
		star.ImageColor3 = Color3.fromRGB(255, 255, 255)
	end
	
	if tonumber(game.Players.LocalPlayer:GetAttribute("AutoSkip")) < chance then
		if (tonumber(game.Players.LocalPlayer:GetAttribute("AutoEquip")) > chance) or (game.Players.LocalPlayer.Auras.Value == game.Players.LocalPlayer.Max.Value) then
			skipButton.Visible = true
			equipButton.Visible = true
		elseif tonumber(game.Players.LocalPlayer:GetAttribute("AutoEquip")) < chance and game.Players.LocalPlayer.Auras.Value ~= game.Players.LocalPlayer.Max.Value then
			print("Equip: " .. tostring(result))
			equipEvent:FireServer(result)
			
			mainEvent:FireServer(1, "aurasValue")
			
			-- create a button
			local btn = exampleBtn:Clone()
			btn.Parent = invFrame
			btn.Visible = true
			btn.Text = tostring(result)
			btn.TextColor3 = color
			btn.UIStroke.Color = color
			btn.FontFace = font
			btn.Chance.Value = chance

			local auraBtn : TextButton = collectionFrame[tostring(result)]
			auraBtn.Locked.Value = false
			auraBtn.Text = tostring(result)
			auraBtn.TextColor3 = color
			auraBtn.FontFace = font
			auraBtn.Interactable = true

			print("Weighted Result: " .. result)
			
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		end
	else
		print("Weighted Result: " .. result)
		
		mainEvent:FireServer(1, "roll")

		blackFrame.Visible = false
		skipButton.Visible = false
		equipButton.Visible = false

		script.Parent.Frame.Transparency = 0.45
		script.Parent.Frame.Size = UDim2.fromScale(1, 1)
		game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

		task.wait(cooldown)
		db = false
	end
	
	local equippedAnAura = false
	local equipWarned = false
	local showedEquipWarning = false
	
	skipButton.MouseButton1Click:Connect(function()
		local warned = false
		if chance > specialChance then
			blackFrame.Warning.Visible = true
			warned = true
		end
		if warned == true then
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false

			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		else
			print("Skipped: " .. tostring(result))
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		end
	end)
	
	equipButton.MouseButton1Click:Connect(function()
		if game.Players.LocalPlayer.Auras.Value ~= game.Players.LocalPlayer.Max.Value and equippedAnAura == false then
			equippedAnAura = true
			
			print("Equip: " .. tostring(result))
			equipEvent:FireServer(result)
			
			mainEvent:FireServer(1, "aurasValue")
			
			-- create a button
			local btn = exampleBtn:Clone()
			btn.Parent = invFrame
			btn.Visible = true
			btn.Text = tostring(result)
			btn.TextColor3 = color
			btn.UIStroke.Color = color
			btn.FontFace = font
			btn.Chance.Value = chance
			
			local auraBtn : TextButton = collectionFrame[tostring(result)]
			auraBtn.Locked.Value = false
			auraBtn.Text = tostring(result)
			auraBtn.TextColor3 = color
			auraBtn.FontFace = font
			auraBtn.Interactable = true
			
			print("Weighted Result: " .. result)

			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			blackFrame.Warning.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		elseif game.Players.LocalPlayer.Auras.Value == game.Players.LocalPlayer.Max.Value and equipWarned == false then
			equipWarned = true
		elseif equipWarned == true then
			blackFrame.Warning.Visible = true
			blackFrame.Warning.Text = "Not enough storage! (if you click equip, a random aura from your inventory will get deleted)"
			showedEquipWarning = true
		elseif game.Players.LocalPlayer.Auras.Value == game.Players.LocalPlayer.Max.Value and showedEquipWarning == true then
			for _, child in pairs(invFrame:GetChildren()) do
				if child:IsA("TextButton") then
					child:Destroy()
					mainEvent:FireServer(-1, "aurasValue")
					break
				end
			end
			
			print("Equip: " .. tostring(result))
			equipEvent:FireServer(result)
			
			-- create a button
			local btn = exampleBtn:Clone()
			btn.Parent = invFrame
			btn.Visible = true
			btn.Text = tostring(result)
			btn.TextColor3 = color
			btn.UIStroke.Color = color
			btn.FontFace = font
			btn.Chance.Value = chance
			
			local auraBtn : TextButton = collectionFrame[tostring(result)]
			auraBtn.Locked.Value = false
			auraBtn.Text = tostring(result)
			auraBtn.TextColor3 = color
			auraBtn.FontFace = font
			auraBtn.Interactable = true
			
			print("Weighted Result: " .. result)

			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		end
	end)
end)
skipButton.MouseButton1Click:Connect(function()
		local warned = false
		if chance > specialChance then
			blackFrame.Warning.Visible = true
			warned = true
		end
        equippedAnAura = false -- Added this to reset equipping an aura.
		if warned == true then
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false

			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		else
			print("Skipped: " .. tostring(result))
			mainEvent:FireServer(1, "roll")
			
			blackFrame.Visible = false
			skipButton.Visible = false
			equipButton.Visible = false
			
			script.Parent.Frame.Transparency = 0.45
			script.Parent.Frame.Size = UDim2.fromScale(1, 1)
			game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), { Transparency = 1, Size = UDim2.fromScale(0, 1) }):Play()

			task.wait(cooldown)
			db = false
		end
	end)```

Could you try this

this shouldnt do anything since equippedAnAura is reseted to false everytime you roll but ill try anyways

it doesnt work:

image

I could be wrong but I’m pretty sure you’re having a connection stack issue.

Every time rollEvent.OnClientEvent fires you nest fresh MouseButton1Click connections inside it, after a few rolls you’re sitting on a stack of old handlers that still reference the previous result/chance variables

Once you press Skip, those stale functions ‘short-circuit’ the new ones, so the Equip button seems to “stop working”.

Updated script that disconnects old button handlers before making new ones, let me know how this works out:

local rp = game:GetService("ReplicatedStorage")
local ss = game:GetService("SoundService")
local equipEvent = rp.EquipAura
local rollEvent = rp.Roll
local mainEvent = rp.MainEvent
local button = script.Parent
local Auras = require(rp:WaitForChild("Auras"))

local invFrame = script.Parent.Parent.Parent:WaitForChild("Tabs").Inventory:WaitForChild("ScrollingFrame")
local collectionFrame = script.Parent.Parent.Parent:WaitForChild("Tabs").Collection:WaitForChild("ScrollingFrame")
local exampleBtn = invFrame:WaitForChild("Example")

local db = false
local specialChance = 1000
local cutsceneChance = 10000

local equipConn
local skipConn

local function auraTick(nameTxt, chanceTxt)
    local aura = Auras[math.random(1, #Auras)]

    nameTxt.Text = tostring(aura.name)
    nameTxt.Position = UDim2.fromScale(.5, .46)
    nameTxt.TextColor3 = aura.color
    nameTxt.FontFace = aura.font
    game.TweenService:Create(nameTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.fromScale(.5, .48)}):Play()

    chanceTxt.Text = "1 in " .. tostring(aura.chance)
    chanceTxt.Position = UDim2.fromScale(.5, .515)
    chanceTxt.TextColor3 = aura.color
    chanceTxt.FontFace = aura.font
    game.TweenService:Create(chanceTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.fromScale(.5, .535)}):Play()

    ss.Tick:Play()
end

button.MouseButton1Click:Connect(function()
    if not db and not game.Players.LocalPlayer:GetAttribute("AutoRoll") then
        db = true
        rollEvent:FireServer()
    end
end)

rollEvent.OnClientEvent:Connect(function(result, chance, color, font)
    local blackFrame = script.Parent.Parent.Frame
    local star = blackFrame.Star
    local vignette = blackFrame.Vignette
    local nameTxt = blackFrame.AuraName
    local chanceTxt = blackFrame.AuraChance
    local skipButton = blackFrame.SkipAura
    local equipButton = blackFrame.EquipAura

    if equipConn then equipConn:Disconnect() end
    if skipConn then skipConn:Disconnect() end

    local cooldown = game.Players.LocalPlayer:GetAttribute("Cooldown")
    blackFrame.Visible = true

    for _ = 1, 4 do
        auraTick(nameTxt, chanceTxt)
        task.wait(cooldown - 0.25)
    end

    nameTxt.Text = tostring(result)
    nameTxt.Position = UDim2.fromScale(.5, .46)
    nameTxt.TextColor3 = color
    nameTxt.FontFace = font
    game.TweenService:Create(nameTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.fromScale(.5, .48)}):Play()

    chanceTxt.Text = "1 in " .. tostring(chance)
    chanceTxt.Position = UDim2.fromScale(.5, .515)
    chanceTxt.TextColor3 = color
    chanceTxt.FontFace = font
    game.TweenService:Create(chanceTxt, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.fromScale(.5, .535)}):Play()

    ss.Tick:Play()
    task.wait(cooldown - 0.25)

    if chance >= specialChance and chance < cutsceneChance then
        blackFrame.Transparency = 0
        vignette.Visible = true
        vignette.ImageTransparency = 1
        vignette.ImageColor3 = color
        game.TweenService:Create(vignette, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {ImageTransparency = 0}):Play()
        task.wait(4)
        ss.NormalBoom:Play()
        blackFrame.Transparency = 0.45
        vignette.ImageColor3 = Color3.new(1, 1, 1)
        vignette.ImageTransparency = 1
    elseif chance >= cutsceneChance then
        ss.Shine:Play()
        blackFrame.Transparency = 0
        star.Visible = true
        vignette.Visible = true
        star.ImageColor3 = color
        vignette.ImageColor3 = color
        vignette.ImageTransparency = 0
        star:TweenSize(UDim2.fromScale(0.5, 0.5), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 4)
        game.TweenService:Create(star, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Rotation = math.random(360, 540)}):Play()
        task.wait(4)
        star:TweenSize(UDim2.fromScale(1, 1), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 4)
        task.wait(4)
        ss.SpecialBoom:Play()
        blackFrame.Transparency = 0.45
        vignette.Visible = false
        vignette.ImageColor3 = Color3.new(1, 1, 1)
        vignette.ImageTransparency = 1
        star.Visible = false
        star.Size = UDim2.fromScale(1, 1)
        star.Rotation = 0
        star.ImageColor3 = Color3.new(1, 1, 1)
    end

    local function finishRoll()
        blackFrame.Visible = false
        skipButton.Visible = false
        equipButton.Visible = false
        script.Parent.Frame.Transparency = 0.45
        script.Parent.Frame.Size = UDim2.fromScale(1, 1)
        game.TweenService:Create(script.Parent.Frame, TweenInfo.new(cooldown), {Transparency = 1, Size = UDim2.fromScale(0, 1)}):Play()
        task.wait(cooldown)
        db = false
    end

    local function createInventoryButton()
        local btn = exampleBtn:Clone()
        btn.Parent = invFrame
        btn.Visible = true
        btn.Text = tostring(result)
        btn.TextColor3 = color
        btn.UIStroke.Color = color
        btn.FontFace = font
        btn.Chance.Value = chance
        local auraBtn = collectionFrame[tostring(result)]
        auraBtn.Locked.Value = false
        auraBtn.Text = tostring(result)
        auraBtn.TextColor3 = color
        auraBtn.FontFace = font
        auraBtn.Interactable = true
    end

    if tonumber(game.Players.LocalPlayer:GetAttribute("AutoSkip")) < chance then
        if tonumber(game.Players.LocalPlayer:GetAttribute("AutoEquip")) > chance or game.Players.LocalPlayer.Auras.Value == game.Players.LocalPlayer.Max.Value then
            skipButton.Visible = true
            equipButton.Visible = true
        else
            equipEvent:FireServer(result)
            mainEvent:FireServer(1, "aurasValue")
            createInventoryButton()
            mainEvent:FireServer(1, "roll")
            finishRoll()
        end
    else
        mainEvent:FireServer(1, "roll")
        finishRoll()
    end

    local equippedAnAura = false
    local equipWarned = false
    local showedEquipWarning = false

    skipConn = skipButton.MouseButton1Click:Connect(function()
        if chance > specialChance and not showedEquipWarning then
            blackFrame.Warning.Visible = true
            showedEquipWarning = true
            return
        end
        mainEvent:FireServer(1, "roll")
        finishRoll()
    end)

    equipConn = equipButton.MouseButton1Click:Connect(function()
        if game.Players.LocalPlayer.Auras.Value ~= game.Players.LocalPlayer.Max.Value and not equippedAnAura then
            equippedAnAura = true
            equipEvent:FireServer(result)
            mainEvent:FireServer(1, "aurasValue")
            createInventoryButton()
            mainEvent:FireServer(1, "roll")
            finishRoll()
            return
        end
        if game.Players.LocalPlayer.Auras.Value == game.Players.LocalPlayer.Max.Value and not equipWarned then
            equipWarned = true
            return
        end
        if equipWarned then
            blackFrame.Warning.Visible = true
            blackFrame.Warning.Text = "Not enough storage! (click equip again to overwrite a random aura)"
            equipWarned = false
            showedEquipWarning = true
            return
        end
        if showedEquipWarning then
            for _, child in ipairs(invFrame:GetChildren()) do
                if child:IsA("TextButton") then
                    child:Destroy()
                    mainEvent:FireServer(-1, "aurasValue")
                    break
                end
            end
            equipEvent:FireServer(result)
            createInventoryButton()
            mainEvent:FireServer(1, "roll")
            finishRoll()
        end
    end)
end)

2 Likes

thx, not only did you fix the issue, you also improved my code, thank you!

1 Like

Glad to see it got fixed, if you really want to improve you code base, you should remove game.TweenService and replace it with local TweenService = game:GetService("TweenService") then remove all the game.Players.LocalPlayer and replace it with local Player = game:GetService("Players").LocalPlayer You could also split your code into functions for when handling the MouseButton1Clicks, always remember to refactor your code so its more readable to you in the future, but it doesnt need to be perfect!

yeah, i should remember that, thanks!

1 Like

I’ve just found another problem with the script, now what happens is everytime i click the equip button it clones the aura twice (like the problem i described firstly), but now theres no need to press the skip button before, i’ve added some things to the script but not that many.