Attempt to compare nil <= number ; i need help before my game launches

Hey, I have a problem with my local script for an ability upgrade, i need help asap bc my game is launching in less then 7 hours, please help, i keep getting this error:

Players.yololol2006.PlayerGui.Ability.Ability_Shop.Ability.DoubleCoins.Inner.Upgrade!.LocalScript:17: attempt to compare nil <= number

this is my code:

local upgradePrices = {100,250,600,1000,2500,4500,7500}
local cooldownTimes = {20,15,13,10,7,5,3}

local function get()
    script.Parent.Upgrds.OnClientEvent:Connect(function(upgrds)
        script.Parent.Parent["AFK VLOGS"].Text = string.format("AFK VLOGS (%u VLOGS)",upgradePrices[upgrds])
        print(upgrds)
        return upgrds
    end)
end

script.Parent.MouseButton1Click:Connect(function()
    local upgrds = get()
    local plr = game.Players.LocalPlayer
    
    print(upgrds)
	    if plr.leaderstats.Vlogs.Value >= upgradePrices[upgrds] then
        if  plr.PlayerGui.Clicker:WaitForChild("AFrontShadeFree") then
            
            plr.PlayerGui.Clicker:WaitForChild("AFrontShadeFree"):Destroy()
            
            plr.leaderstats.Vlogs.Value = plr.leaderstats.Vlogs.Value - upgradePrices[upgrds]
            plr.PlayerGui.Clicker.CoolDown.Value = cooldownTimes[upgrds + 1]
            
            script.Parent.Upgrds:FireServer(upgrds + 1)
        else
            plr.leaderstats.Vlogs.Value = plr.leaderstats.Vlogs.Value - upgradePrices[upgrds]
            plr.PlayerGui.Clicker.CoolDown.Value = cooldownTimes[upgrds + 1]
            script.Parent.Upgrds:FireServer(upgrds + 1)
        end
        
    elseif upgrds >= 4 then
        script.Parent.Text = "Max upgrade!"
    end
    
end)

???

upgradePrices[upgrds]

This function is problematic:

local function get()
    script.Parent.Upgrds.OnClientEvent:Connect(function(upgrds)
        script.Parent.Parent["AFK VLOGS"].Text = string.format("AFK VLOGS (%u VLOGS)",upgradePrices[upgrds])
        print(upgrds)
        return upgrds
    end)
end

It does not return any value at all. It just connections functions, which I would almost never recommend.

oh ok, and how do i fix sorry for asking

Problem is that upgrds variable inside function that is connected to MouseButton1Click is nil because get function actually doesn’t return anything and only creates a new RBXScriptConnection every time button is clicked. You should yield the code until OnClientEvent fires by using script.Parent.Upgrds.OnClientEvent:Wait() instead:

local function get()
    local upgrds = script.Parent.Upgrds.OnClientEvent:Wait()
    script.Parent.Parent["AFK VLOGS"].Text = string.format("AFK VLOGS (%u VLOGS)",upgradePrices[upgrds])
    print(upgrds)
    return upgrds
end

ok, where do i put it, the reason why i sound stupid is bc im new to scripting and my friend scripted this but he is offilne till the game launch

You put this code where get function is in your code.

ok thx it worked
thank you for the help