How do I update a prop manipulator's prop list dynamically?

I’m trying to make a mining game similar to azure mines / mining simulator on Roblox. However, I’m having trouble detecting when the blocks get hit.

I want the blocks to detect when they get hit with a pickaxe so I can update their HP and give the player resources if the block breaks. The only way I could find out how to do this was with prop manipulators, but I also want the blocks to be generated procedurally which means I cant assign the blocks to prop manipulators in the editor. I tried making a prop manipulator affect an area then spawn blocks in that area, but they didn’t get appended to the prop manipulator.

Anyone know how I can do that?

That isn’t currently possible- you can detect when a block has been disposed by looping over it and checking IsDisposed[] but it won’t give you the instigating player that destroyed it.

1 Like

Are you sure IsDisposed[] tells you when a prop’s been broken? It doesn’t seem to work from my testing.

Yes. If it’s something you haven’t implemented before, then you might want to post the code to show how you were assuming it is used and I can tell you if there is an issue with your usage of it.

1 Like

I store all the instances of cubes inside of a big array called instblocks. I’m looping over all of them and checking if they’re disposed, but for some reason it never prints the message. I spawn this function in OnBegin and I’ve verified that the function IS running and looping over every block. I also tried a similar approach on a single creative prop but that didn’t detect being destroyed either.

    UpdateDetectors()<suspends>:void=
        loop:
            Sleep(0.2)
            var offset : int = 0
            for(i:=0..instblocks.Length-1):
                if(item := instblocks[i-offset], prop := item.pinst?):
                    if(prop.IsDisposed[] = true):
                        Print("block DEAD!!!! :O", ?Duration:=6.0)
                        if(newarr := instblocks.RemoveElement[i-offset]):
                            set instblocks = newarr
                        set offset += 1

Not sure what I’m doing wrong

Have you put in some print statements to debug which if statement is failing, if any? That’s the first thing you should check in a situation like this.

1 Like

Yes, everything’s working fine except the if(prop.IsDisposed[] = true): line.

<decides> functions are checked by doing if (prop.IsDisposed[]), it doesn’t return true or false.

1 Like

Oh, my bad. It works now. I Thought not comparing it to true was throwing me an error earlier, but I guess that was unrelated. Thanks for your help!

1 Like