Jump to content

Recommended Posts

Hi, I already made a post asking about this, but I realised it was in the wrong forum so I am reposting here. Apologies if reposts are not allowed.

I am creating a client-side mod that adds different on-hit effects to weapons. For example, attacking with a spear makes a particle effect.

The mod works fine on my own world, but I crash when I join a public world. I think this is because `inst.components.weapon` is not accessible by the client (when I print the keys of `inst.components`, I don't see weapon).

Is there a way to fix this, or is there another method that I can use? I would prefer to keep the mod client-side as it is just a cosmetic mod.

local function SpearEffects(inst, attacker, target)
    inst.components.weapon:SetOnAttack(function(inst, attacker, target)
        -- code for the effects
        -- breaks, attempt to index field 'weapon' (a nil value)
    end)
end

AddPrefabPostInit("spear", SpearEffects)

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
×
  • Create New...