My game keeps crashing

I’m trying to make it in my game ANIMOSITY, that when you assign guns to the same slot the first gun that was assigned to that slot will be removed from said slot. I’ve been working on this for a day but now it keeps making my game crash. I have no idea why this is happening as I don’t see an infinite loop anywhere. (But I’m probably just blind)

I made a copy of the game (since I don’t want to show the rest so far) with one level that has the stuff I’m having a problem with. To assign a gun to a number slot, click the gun and click a number key from 1-5. The code for all of this is in the player, the UI gun buttons, and the brownish one with the pistol in the middle in the UI.
image
image
image
By the way, only the Pistol and Shotgun buttons work right now.

2 Likes

So you want to make a gun storage system, to save what guns you collected?

Yes, I’ve already made that but what I need help with is that now I want it so that if you have 2 guns in the same slot the other 1 gets removed from said slot but it crashes the game

1 Like

You are using a list I am guessing?

Uh… no…
I suck at that

2 Likes

Here is a quick bundle I made.
Add adds a new gun to the list, but it makes sure there are no repeats. Find finds the guns in the list. For example, if the list is;

6,7,8

and you input 1. It will output six.

{"data":{"behavior":{"v":"2","nodes":[{"inputCount":2,"outputCount":1,"name":"Gun Inventory","behaviorType":"logic.NodeGroup","x":-450,"y":-16,"group":"","id":"248f6a5355210f46","notes":"Made by Overma Games","n_o":1,"isMenuItem":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-32,"group":"248f6a5355210f46","id":"248f712dad449048","portId":"248f6a5355210f46i0","tag":"New","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":90,"y":48,"group":"248f6a5355210f46","id":"248f963f08046249","portId":"248f6a5355210f46i1","tag":"Find","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-32,"group":"248faa891769b947","id":"248fbdf71d9f4541","portId":"248faa891769b947i0","tag":"In","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-112,"group":"248faa891769b947","id":"248fde53c78f7547","portId":"248faa891769b947i1","tag":"Set","dataType":3},{"inputCount":7,"outputCount":5,"name":"Number List","behaviorType":"logic.data.NumberList","x":90,"y":-144,"group":"248faa891769b947","id":"248ff9387ac9bb43","startVal":[],"copy":false,"v":2},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":630,"y":-32,"group":"248faa891769b947","id":"2490160629f2df4e","startVal":0,"roundMode":1},{"gateVal":0,"mode":"equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":270,"y":-80,"group":"248faa891769b947","id":"249030665ce47349"},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":810,"y":-16,"group":"248faa891769b947","id":"24905e76e40be247","portId":"248faa891769b947o0","tag":"New","dataType":2},{"delay":0.1,"count":1,"version":2,"inputCount":3,"outputCount":1,"name":"Timer","behaviorType":"logic.triggers.Timer","x":450,"y":-80,"group":"248faa891769b947","id":"2494b59dbaeb8842"},{"inputCount":2,"outputCount":1,"name":"List","behaviorType":"logic.NodeGroup","x":90,"y":-32,"group":"248f6a5355210f46","id":"248faa891769b947","isMenuItem":false},{"inputCount":7,"outputCount":5,"name":"Number List","behaviorType":"logic.data.NumberList","x":270,"y":-32,"group":"248f6a5355210f46","id":"249089aac43a0f48","startVal":[],"copy":false,"v":2},{"inputCount":2,"outputCount":1,"name":"Save Number List","behaviorType":"logic.logic.Storage","x":90,"y":-144,"group":"248f6a5355210f46","id":"2490ee09cb7c6541","storageKey":"Guns Save 002","dataType":3},{"inputCount":0,"outputCount":1,"name":"Once","behaviorType":"logic.triggers.Once","x":-90,"y":-128,"group":"248f6a5355210f46","id":"24911cbe4c390a4d","resetOnLevelStart":false},{"inputCount":1,"outputCount":1,"name":"Number List Order","behaviorType":"logic.data.ListOrder","x":270,"y":-144,"group":"248f6a5355210f46","id":"249138ff45640642","mode":1,"copy":false,"numSort":false},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":450,"y":0,"group":"248f6a5355210f46","id":"2495183ff607294c","portId":"248f6a5355210f46o0","tag":"Found","dataType":2}],"links":[{"input_id":"248faa891769b947i0","output_id":"248f712dad449048o0"},{"input_id":"249089aac43a0f48i3","output_id":"248f963f08046249o0"},{"input_id":"248ff9387ac9bb43i6","output_id":"248fbdf71d9f4541o0"},{"input_id":"2490160629f2df4ei0","output_id":"248fbdf71d9f4541o0"},{"input_id":"248ff9387ac9bb43i0","output_id":"248fde53c78f7547o0"},{"input_id":"249030665ce47349i1","output_id":"248ff9387ac9bb43o4"},{"input_id":"24905e76e40be247i0","output_id":"2490160629f2df4eo0"},{"input_id":"2494b59dbaeb8842i0","output_id":"249030665ce47349o0"},{"input_id":"2490160629f2df4ei1","output_id":"2494b59dbaeb8842o0"},{"input_id":"249089aac43a0f48i1","output_id":"248faa891769b947o0"},{"input_id":"249089aac43a0f48i2","output_id":"248faa891769b947o0"},{"input_id":"2490ee09cb7c6541i0","output_id":"249089aac43a0f48o0"},{"input_id":"249138ff45640642i0","output_id":"249089aac43a0f48o0"},{"input_id":"248faa891769b947i1","output_id":"249089aac43a0f48o0"},{"input_id":"2495183ff607294ci0","output_id":"249089aac43a0f48o1"},{"input_id":"249138ff45640642i0","output_id":"2490ee09cb7c6541o0"},{"input_id":"248faa891769b947i1","output_id":"2490ee09cb7c6541o0"},{"input_id":"2490ee09cb7c6541i1","output_id":"24911cbe4c390a4do0"},{"input_id":"249089aac43a0f48i0","output_id":"249138ff45640642o0"}]}}}

I hope this works for you, if not let me know.

1 Like

Where do I paste the code?

1 Like

Into whatever object that would have the gun inventory. Hope it works!

1 Like

Agh, sorry, this is kind of confusing is there like a long detailed explanation to this?
I really need to learn lists.

1 Like

Sure! When you get a new weapon, you use the add input. When you use the number keys (example 1-5) you put that into the get input. The output outputs what gun is being used right now. Does that make any sense? lol. I am terrible at explaining things.

1 Like