Skip to content
Advertisement

How do I make sure that the person has a certain item from the shop?

I’ve had this problem for hours where I can’t make sure that people have bought a pet before doing activities with it.

It doesn’t show an error but it doesn’t work properly and I don’t know how to reference a certain item in a player’s inventory because I’m trying to implement a pet feature where you can fight pets with other people and also will be able to feed your pet and there will be events like pet races and stats etc.

JavaScript

Advertisement

Answer

Your string concatenation is wrong. There shouldn’t be an exclamation mark before the strings after target.id.

If you do this, it’ll concatenate the truthy value, converted to a string, so ‘false’ in this case.

What you have right now (bad)

JavaScript

What you need (good)

JavaScript

It should work if you just remove the ! from db.has

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement