How would i make a deck creation system?

Hello, i’m making a PVZ1 Fanmade game on Roblox and i’ve been wondering what would i need to use to make a deck system, the way it functions is that there’s a plant selection menu and a plant inv on top of the screen. When you click on a plant in the selection menu you have to click on the slot you want to equip it on. I’ve been trying a few methods but they end up glitching and being too long, could ya’ll please help me with that?

How my gui looks:


How it looks in the OG Game:

1 Like

hmm
i mean i would kinda detect clicks from the selectionMenu, making variable currentlySelectedPet = x and set it to that pet you clicked. Then when clicking inventory if currentlySelectedPet ~= nil add the pet to inventory, and darken the selectionMenu pet image

for removing pets from inventory, just detect if the inventorySlot youre clicking on is empty. if not, remove the pet and un-darken the selectionMenu slot for that pet

if you wanna save the setup to server for datastores, you can send the inventory as a remote when it changes. when game starts just fire up another remote on the client so it loads the inventory and subtracts inventory pets from selectionMenu, we dont need to ever datastore it because inventory is like its counterpart

but thats the strat id use i guess

1 Like

I tried this and i can select every slots and it’ll add the same plant over and over

1 Like

yeah i figured it out. but try to bugfix it yourself first if you can, wasnt that hard to fix. or maybe its kinda hard for a new scripter, but anyway i created a recap of the fixed steps below. that should work

what i did was basically add more checks, like if inventory slot is empty etc. And when the pet gets in inventory setting the currentlySelectedPet to nil, and so on
oh yeah if you ever try bugfixing yourself use logic maps like the one below. they make it super easy

recap
  • make variable currentlySelectedPet
  • petSelectionMenuSlot clicked → check if pet is in inventory → if not, update currentlySelectedPet and do some cool selection visuals
  • inventorySlot clicked → if slot empty and currentlySelectedPet not in inventory and currentlySelectedPet ~= nil, add pet to inventory and set currentlySelectedPet to nil. If slot isnt empty and currentlySelectedPet == nil then remove from inventory / add it back to selectionMenu

extra notes

  • inventory and selectionMenu are kinda the opposite, so adding anything in inventory removes it from selectionMenu and vice versa. remember to code that in the “add pet to inventory” spots and so on
  • you cant save models to datastore, so remember to decode the inventory sent to server into the models names. those can be saved
  • if you wanna implement datastores, when loading to client see if data exists. If not then set inventory to zero pets and petSelectionMenu to all or zero pets depending if they need to be bought. If data does exist just use that
3 Likes

I got a question tho, how would i define a slot without using 99 times Slot1/Slot2/Slot3/Slot4… .MouseButton1Click:Connect()?

1 Like
1 Like