[SOLVED] Help with pickup items

I am making an fps and want to be able to pick up and throw guns. I have absolutely no idea how to make a script for this.I want to make it so that when you also throw the gun if it hits an enemy it would kill it.

Hi @Connor_Briggs! Look at the post below. In that post @Fus_ion shared two scripts that you can use (as example).

the thing is i tried using that code but i couldn’t get it to work but i’ll try again i reply if it didn’t work

You probably need to make some adjustments (in both the script and your project) for it to work. If it doesn’t work, please share a link of your project so I can take a look.

so i put it in my project but it has errors

some one is in my project whoever it is plz stop

Please don’t multi-post.

If it’s a public project, then it’s open to everyone to access and look at the project.

okie

hey do you know how to help me make a code to pick up items in me game

yo, I need help with the thing you did on your game, where when the enemy is shot it makes them bleed

okie

Just under where the enemy takes damge do
this.particles.particlesystem.reset();
this.particles.particlesystem.play();

also have a
Enemy.attributes.add(‘particles’, { type: ‘entity’});

see if that works

1 Like

Can you add me to the project and tell me what you try to achieve? Then I can try to make something work. Right now I can’t find your entity to pick up and I also can’t find the entity that you use as inventory.

Oike the items i want to pick is is under m1911

thing is the pistol will always be with the player

I just don’t how to make it so that you can only a pistol and all the other items

i know i am confusting you i sorry

If you add me to your project, I can talk to you inside the project, because this is not a chat.

how do i do that

nevermind

Hey albertos can you help me again

so i have made it so that you can pick up the item now how do i make it so that i drop the gun

To drop a weapon in the scene you have to clone one of the pickable weapons that I made for you.

var player = this.app.root.findByName('player');
var weapon = this.app.root.findByTag('shotgun').clone();
this.app.root.addChild(weapon);
weapon.setPosition(player.getPosition());
weapon.enabled = true;

Note: I remember we use the same name for the pickable weapons as the weapons that are attached to the player, so I suggest to add a tag with the exact same name to your pickable weapons and find the weapon by tag instead of by name.

okie i’ll try that