Raycast part goes inside another part

Here’s the video to see what I’m talking about:


When I put the block on the surface that the arrow is pointing towards, the block goes inside of the red part :confused:

Here’s the game itself:
sendForTesting.rbxl (63.1 KB)
I think it has to do something with the localscript, since that’s what’s ‘rendering’ the gray cube. I think the solution will involve a bunch of math (hopefully not though), but I don’t understand any of it since I took this from B Ricey’s youtube tutorial. Thanks guys!

2 Likes

Okay, I’ve done a lot of testing and here are my conclusions:

The problem axis is the Z axis, so I printed out my raycast.Position, and it gives “number, number, -7”.
image

Then, it gets sent to a moduleScript to do a little bit of math on it. -7/0.25 = -28 * 0.25 = -7.
image

Then, it gets sent back to the localscript for further processing.


not quite sure what this does, but that last line is the error.

Position I want for the block: num, num, -7.125
Position I’m getting: num, num, -6.875

Any way to fix this? Thanks!

1 Like

Here’s another example:
image

num num 6

6/0.25 = 24/0.25 = 6

6+0.125 = 6.125

and that’s the exact position I’m getting! but I want 5.875 (or 6-0.125) instead of what I’m getting

1 Like

Sadly, putting a negative in front of the last value doesn’t work…

please help! Thanks!

1 Like

Two additional helping videos:


1 Like

Anyone?! Please :pray:


1 Like