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.
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.
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.
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
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.