Jump to content

[Need Help] Equipping causes crash when on client


Recommended Posts

Im new to programming, Im trying to make a back pack, when you place gears in side it increases its level, and at level 5 it gets 2 extra slots (initially its an 2x3 inventory using "icepack"). this works on the host, but every time the item is equipped on client the inst.components.container:Open(inst) causes a crash.

ive looked into it, it seems like its to do with how the components are all on host and not client. also it dosnt seem like the inst.name updates for client either.

I dont know, but is there a way host can tell the client when the name and container needs to be updated?

local function CheckForUpgrade(inst)
local container = inst.components.container

    for i = 1, container:GetNumSlots() do
    local item = container:GetItemInSlot(i) or nil
        if item ~= nil and item.prefab == "gears" and inst.level < 5 then
        inst.level = inst.level+1
        container:RemoveItemBySlot(i)
        applyupgrades(inst)
        end

    end

end

function applyupgrades(inst)
inst.name = inst.name.." +"..inst.level
inst.components.equippable.walkspeedmult = 0.8+ inst.level * 0.02 + inst.penalty
inst.components.armor.absorb_percent = 0.3 + inst.level * 0.04
    if inst.level == 5 and inst.components.container.numslots ~= 8 then
    local old_container = {}
    inst.components.container:DropEverything()    
    inst.components.container:WidgetSetup("backpack")
    end
end

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...