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.
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)
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”.
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.