Building system places blocks even when the player has no blocks

I have a building system for my game Survival in the Wilderness but when the player clicks, the block would get placed even if the player doesn’t have any items in their inventory.

Can someone help?

2 Likes

Yeah ok, what object is the code for building in?

The cursor( in the UI tab)

ok, ill try working on it later, but the code isnt showing up for me for some reason. In the meantime, you should make it so that between the clicking and the placing of the block, there is a switch set to on. Now from the number block that stores the amount of blocks you have left, use a filter set to less than 0 to determine if you have any blocks left. If it passes, you turn off the switch. Then another filter coming from the same number, this time more than 0. if that, passes, turn the switch back on. Sorry if this was a bad explanation because for some reason i cant see the lines connecting the blocks.

OK, but I already tried doing something like that.
I had a global that contained the amount of blocks i had, and had it so if you had less than 1 block, it would turn off a switch that would stop the player from building and if you had more than 0, you could place blocks.
But it didn’t work.

Ok ill have a look later but i gtg for now

Once you fill out the globals for all of the resources, you can make something like this for each block:

If the global is greater than 0, then the switch turns on and you can place blocks. It’s pretty simple.

1 Like

@Flying_Fajita For some reason, the code didn’t work.


My exact code.
I did everything the picture told me, and it didn’t work.

Ya that’s because the wood global isn’t being updated. You have to make the wood global ACTUALLY the number of wood the player has.

It WORKS!
"Thanks! @Flying_Fajita

Nice