For interact-able assets like the one shown above, using a loop to check magnitude would work but could cause issues if there are a lot of torches. Are there any other approaches to doing this? I’ve considered using .Touched
and .TouchEnded
with an invisible block but in my experience those functions aren’t very reliable.
I would use .Touched
and .TouchEnded
for this and make the parts the size of the Magnitude
that you would check for if you were to use a loop. I would also have a table of players that are already touching the part so that when multiple BodyParts of the character touch the part you are using to detect, it doesn’t flag the .Touched command a million times.
The thing is .TouchEnded
has weird behavior. It seems to fire even if the player is still touching the brick.
Well, yes and no. It fires every time a body part of the character stops touching the block as well, which is why if the person is standing half in and half out, the body parts that are no longer touching the part would fire the .TouchEnded
event.
The solution for this would be, as I mentioned, to have a table of the player’s characters and check if the part that fired the .Touched
or .TouchEnded
events is in the table. If it is in the table, you have already dealt with another part of the character, so ignore this firing of the event. If it isnt, add the player character to the table and do whatever you would do when the player touches the part.
So I’ve found a solution. I check if the part is touched then run through separate checks with GetTouchingParts as to bypass the weird behavior of .TouchEnded
.