Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

GetTouchingParts, loop that instead..

3 answers

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?

1 comment

0

The issue is that the sensor doesn't detect the block. It doesn't print "hit".

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)

1 comment

0

The issue is that the sensor doesn't detect the block. It doesn't print "hit".

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.