Oh, I didn’t notice you replaced your previous code, it wasn’t in your new snippet.
This will always equate to false, you’re comparing a Vector3
with a table of parts.
Oh, I didn’t notice you replaced your previous code, it wasn’t in your new snippet.
This will always equate to false, you’re comparing a Vector3
with a table of parts.
I know it’s bad because it doesn’t work, but I’m thinking how to make it work
You’re always comparing clientStructure.Position
to a table of parts here. Even if you were to iterate over the array of parts and compare each one individually, the part would have to be exactly at the same position (at the centre of) the structure. You need to change that logic for your code to work.
If you give me some more information about what clientStructure
is, I can help you more with fixing this. All I can tell right now is that it’s an instance cloned from ReplicatedStorage
.
you still should change your raycast method
ClientStructures - contains all available structures, which will be used on the map, so I want to check if the clientStructures is in node so that the player cannot place this object anywhere else
Do you mean that you want to check if the two parts are intersecting? Or that you want to see if the player has already placed a structure of that type?
I would like it to work in such a way that when the clientStructure goes outside the node, it cannot be placed
– Visualization
Change this to
if #partsInPart > 0 then
partsInPart is the number of parts inside the node, if it is 0 then it is outside.
You helped a lot, but now the only problem is how to check whether the mouse is in this zone
Oh right, sorry about that, scratch the previous solution and just check if the part is fully inside the node
With this, you have to create special lines for this, and I just want to check the square and check it without creating lines in it
GetPartsInPart probably doesn’t work becasue canquery is set to false. Try using a different spatial query method.
Try finding the correct solution on the devform. Here I’ve found another one for you to test: How to detect if a part is completely within another part? - #13 by Joshument
This works best for now, but the biggest problem is that it checks whether the clientStructure is in the node and it doesn’t check the mouse, so now how to deal with it?
Why do you need to check for the mouse?
however, it does not have to check the mouse, which is why, as I thought, but somehow it has to check whether the object is completely in the node
If you get a solution that checks if the part is completely in the node then you don’t need to check for mouse. Even if you checked for mouse, if your mouse is inside and you rotate the part, it would be sticking out which is something you don’t want.
that’s actually right, but now the question is what to do to make node verify whether the entire model is in node
I explain how to calculate if something is within a specific area here.
Now I don’t have any problems with calculating whether I am in the zone, I just have a problem with preventing the object from leaving the zone.
For your object, get it’s bounding box. Use that to calculate all 8 corners. Your object is guaranteed to be in between those corners. Then just make sure no corners are outside of the area.