#*NOT SOLVED* Client Not Getting Table Key

1 messages · Page 1 of 1 (latest)

strange heart
#

im trying to send table data with number keys to the client to update ui but the client is only receving one out of the two keys

Server Script below

local function Default_item_info(info)
    local Founditeminfo = iteminfoModule.items[info.Name] or iteminfoModule.Materials[info.Name]
    local thumbnail =  Founditeminfo and Founditeminfo.Thumbnail and Founditeminfo.Thumbnail.Image or ""
    local newSlot = table.clone(iteminfoModule.Struct)
    local infoTable  = {}
    print("Slot Data >>>>>>>>>>>>> ",info)
    if info.Name == nil then
         infoTable = {
            Name = nil,
            Amount = 0,
            Stack = 0,
            Thumbnail = "",
            Type = "",
        }
    else
         infoTable = {
            Name = info.Name,
            Amount = info.Amount,
            Stack = info.Stack,
            Thumbnail = thumbnail,
            Type = info.Type,
        }
    end

    return infoTable
end

module.SwapSlots = function(player,StartSlot,EndSlot)
    local inventory = PlayerStats.GetPlayerinventory(player)
    print(StartSlot,EndSlot)
    
    local StartSlotData = inventory[tonumber(StartSlot)]
    local EndSlotData = inventory[tonumber(EndSlot)]
    
    inventory[tonumber(StartSlot)] = EndSlotData
    inventory[tonumber(EndSlot)] = StartSlotData
    
    
    local ToUpdate = {[tonumber(StartSlot)] = Default_item_info(EndSlotData),[tonumber(EndSlot)] = Default_item_info(StartSlotData)}
    print("Players inventory >>>>>>>>>>>>>>>>>>>>>>>>>>>",inventory)
    print("To Update >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",ToUpdate)
    updateSlotUI:FireClient(player,ToUpdate)
end
strange heart
#

NOT SOLVED Client Not Getting Table Key

finite wasp
#

use table.create and table.insert

strange heart
#

ālso this only happens with slot one aka [1]

finite wasp
#

merge the tables and send it as 1 table

strange heart
#

wouldn't that make more issues like extracting the info and what slot it belongs to

finite wasp
#

thsts fine you can fire 2 events even then you have 2 seperate tables and u can save them right

#

or u can store them in like a db module?

strange heart
#

okay i fixed and it makes no sense at why this works

#

local ToUpdate = {[StartSlot] = Default_item_info(EndSlotData),[EndSlot] = Default_item_info(StartSlotData)}
print("Players inventory >>>>>>>>>>>>>>>>>>>>>>>>>>>",inventory)
print("To Update >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",ToUpdate)
updateSlotUI:FireClient(player,ToUpdate)

getting rid of the tonumber() fixed it?

#

im guessing when using to number if there is anything like ?,:,_ etc. it will return nil

half osprey
#

serialization throws away mismatched key types

#

if you got index as number and other as string

#

it will yeet one of them out

#

maybe thats what happend?

#

or maybe its struggling to send enum

strange heart
#

prob