No output on .Touched

I want the script to fire the event whenever the small part touched the big green part (look video). When they touch, nothing happens. Both of them are CanCollide = false.

Example

This is literal simplicity, yet I still have no idea what is going on.

local instruction = "Forward"
cd = false

script.Parent.Touched:Connect(function(hit)
	if cd == false then	
		if hit.Name == "AutoGate_GearSensor" then
			cd = true
				
			script.Parent.Parent.Instructions:Fire(instruction)
			
			task.wait(1)
			cd = false
		end
	end
end)
1 Like
script.Parent.Parent.Instructions:Fire(instruction)

Is this a remote event? if so I don’t think :Fire() is a function.
However :FireClient(player) ,:FireServer() and FireAllClients() are

1 Like

It’s a BindableEvent. s

1 Like

is ball tweening?
charcharchar

1 Like

I’ve put some prints to check where the problem was, and it seems to be that the .Touched function doesn’t recognize the part as “AutoGate_GearSensor”.

1 Like

What is the script for the Event for the Bindable Event

No, it’s just a for i to show how it’s supposed to travel.

1 Like
script.Parent.Instructions.Event:Connect(function(instruction)
	print(instruction)
end)
1 Like

Is the property for the ball CanTouch enabled?

1 Like

Yes. CanTouch is enabled, CanCollide is disabled.

2 Likes

Have you tried having the TouchEvent just print the names of the parts touching it?

Yes. It doesn’t work with the part, but I tried on my avatar and it worked for some reason.

How is that supposed to help me in any way? I don’t want the part tweening or moving. I just want it to be detected while touching.

I’m running out ou ideas, but have you tried running the script in studio and moving the part to touch the other part.

If that doesn’t work, yet other parts do, it may be something to do with the properties of the part

Try to print hit Name, like this:

local instruction = "Forward"
cd = false

script.Parent.Touched:Connect(function(hit)
        print(hit)
	if cd == false then	
		if hit.Name == "AutoGate_GearSensor" then
			cd = true
				
			script.Parent.Parent.Instructions:Fire(instruction)
			
			task.wait(1)
			cd = false
		end
	end
end)
cd = false

script.Parent.Touched:Connect(function(Hit)
	if cd == false then
		if Hit.Name == "AutoGate_GearSensor" then
			cd = true
			local instruction = "Right"
			script.Parent.Parent.Instructions:Fire(instruction)
			task.wait(1)
			cd = false
		end
	end
end)
``

Managed to find a fix, this works for some reason. Thanks everyone tho.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.