Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to have a part detect that its touching another part that is anchored?

Asked by 4 years ago

Seems like a dumb question but I'm trying to set up a sensor that detects if its touching another part(named Block).

TopSensor.Touched:connect(function(hit)
    print "hit"
    if hit.Name == "Block" then
        print(hit.Name)
        TipTriangle.Transparency = 1
        LeftTriangle.Transparency = 1
        RightTriangle.Transparency = 1
    end
end)

It won't actually make contact unless the Block isn't anchored.

0
GetTouchingParts, loop that instead.. greatneil80 2647 — 4y

3 answers

Log in to vote
0
Answered by
sebanuevo 123
4 years ago
Edited 4 years ago

You could do

if hit.Anchored == true then
print("The part is anchored")
else
print("The part is not anchored!")

You catch the idea right?

0
The issue is that the sensor doesn't detect the block. It doesn't print "hit". DylanD319 9 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
TopSensor.Touched:connect(function(hit)
    print "hit"
    if hit.Name == "Block" then
        if hit.Anchored == true then
            print(hit.Name)
            TipTriangle.Transparency = 1
            LeftTriangle.Transparency = 1
            RightTriangle.Transparency = 1
        else
            hit.CanCollide = false
        end
    end
end)
0
The issue is that the sensor doesn't detect the block. It doesn't print "hit". DylanD319 9 — 4y
Log in to vote
0
Answered by 4 years ago

I put a script inside the Sensor that'd make it stay in place without being anchored

while true do
    wait()
    script.Parent.Position = Vector3.new(script.Parent.Parent.Parent.Block.Position.X, script.Parent.Parent.Parent.Block.Position.Y + 10, script.Parent.Parent.Parent.Block.Position.Z)
    script.Parent.Velocity = Vector3.new(0,0,0)
end

It'll shake constantly but it'll stay in the general area. This did fix my problem. Seeing as the only part it can detect is one that isn't anchored.

Answer this question