When we make a moving part stop when it touches something, but something is wrong?

Thats Part
image

Thats Script
image

Results:
ClientSide
image
ServerSide
image
and

File:(you can test file)
File.rbxl (28.6 KB)

What is the easiest way to solve this?

1 Like

Maybe .Touched fired before it actually touched the baseplate, you could try using region3

1 Like

In your script you have if hit ~= part then return end (Line 7)

This line is telling your script to stop running if it hits a part other than the part you’re trying to anchor. Instead, replace ~= with == and see what you get! :wink:

… wrong
there are no errors in the script, and I wrote it like that for testing purposes

Hey!

My solution would be, that you can execute a raycast to the ground from the part after you anchored it otherwise I wouldn’t know myself a different way how you could approach this.

Cheers

i am using this:
but I don’t think this is the best solution.

local w = Instance.new("Weld")
w.Part0 = Baseplate
w.Part1 = part
w.C0 = Baseplate.CFrame:toObjectSpace(part.CFrame)
w.Parent = w.Part0

I think that not good

Right, there are no errors but that line would prevent you from running any code after that line is executed.

Think about it like this, ~= means does not and your if statement is basically stating the following logic:
if TheObjectThatWasHit Is-NOT TheObjectThatWe'reAnchoring then return end

The correct behaviour (I assume you’re going for) would be:
if hit == part then return end