My trade system doesnt work

So I made this script that should set a value inside of a table called Accepted. And also a value that is Items. Only problem is it doesnt work AT ALL.

It doesnt change the accepted value, nor does it change the items in the table. WHy???

local connect = TradeUpdate.OnServerEvent:Connect(function(plr,trade,Update,other)
    print('Trade update received: '..Update)
    if trades[trade.Plr1.Plr.Name..'_'..trade.Plr2.Plr.Name] then
        local play = nil
        if trade.Plr1.Plr == plr then
            play = trade.Plr1
        else
            play = trade.Plr2
        end
        
        print(play)
        
        if Update == 1  then -- declined
            trades[trade] = nil
            TradeUpdate:FireClient(player,nil)
            TradeUpdate:FireClient(user,nil)
        elseif Update == 2  then -- accepted
            
            print(play.Accepted)

            play.Accepted = not play.Accepted
        elseif Update == 3 then
            if other then
                play.Items = {table.unpack(play.Items), table.unpack(other)}
                print(trade)
            end
        end
    else
        print('Trade doesnt exist')
    end
end)

Okay, first of all we do not have access to your entire game so there is no way of helping you without eyeballing your code or you explaining to us what prints and what doesn’t in your code.

Furthermore, I would use remote functions instead of remote events to handle trading. But that’s just me.

Figured it out. I was changing the table that was sent, not the actual one I wanted to change

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.