System not detecting bogies in the sensor

I was working on my new signalling system for a train game but :GetTouchingParts() function that I used to detect trains on a station is not working. Any mistakes? The code is not returning any error. Running server-side. Here is the code that is not working:

function checksensor(sensor)
for i,v in pairs(sensor:GetTouchingParts()) do if v.Name == “Front” or v.Name == “Wheel” or v.Name == “Wheels” then istrue = true end end
if istrue == true then
return true;
else
return false;
end
end

Code was supposed to return true if there is a detected bogie/wheel or it will return false. The only problem is it is returning false everytime. I tried the a script like this to print which parts are detected and when i try that from the console , it worked and it detected the bogie.

Please show us the part were you call the function. You would have to call this function constantly and not just once.

So have you made the train with the wheels?

And I am not sure what you mean.

Does the light go red or green or does it voice activate a message that says: “The train the is now approaching”?

Explain more for a further explanation.

Here it is:

for _,row in pairs(game.Workspace.FullNetwork:GetChildren()) do
for _s,screen in pairs(row:GetChildren()) do
– Check if screen contains platforms
if screen.ControlGui:FindFirstChild(“Platforms”) == nil then
print(“nope this one doesnt have platforms”)
else
– If there is platforms , load the platforms to the screen
for _ui,platform in pairs(screen.ControlGui.Platforms:GetChildren()) do
– Check for platform on sensors
if game.Workspace.Sensors:FindFirstChild(platform.Name) == nil then
– print(platform.Name …" is not present in game. Renaming required ( SIGNAL_NOT_FOUND )")
else
– If there is the platform , get the status
if checksensor(game.Workspace.Sensors:FindFirstChild(platform.Name)) == true then
platform.BackgroundColor3 = Color3.fromRGB(170,0,0)
for ___,buffer in pairs(platform:GetChildren()) do
if buffer:isA(“ImageLabel”) then
buffer.BackgroundColor3 = Color3.fromRGB(170,0,0)
end
end
print(platform.Name …" found and its full ( SIGNAL_RESULT_TRUE )")
else
print(platform.Name …" found and its NOT Full ( SIGNAL_RESULT_FALSE )")
end
end
end
end
end
end

Some paths and signals are not matching the ones in the controller room this is why it finds for the paths.
Also in the testing i see that it said that the station is empty about 6 time sometimes.

It is an system for control room. When a train touches the path at the station rail , it will detect it and and change the status for that station in signalling room. It is also for signals.

We deciced to fix the old detecting system. So we don’t need help anymore.

And how did you fix it?

As far is i know i make the local driving script do theese functions:

  1. Check if the train touched to an sensor which is in sensors folder
  2. There is a bool value with the same name as the sensor in the sensor debounces folder
  3. If there is one it will function the server to update the status for it

However the game that i was working on is about to be discontinued because the owner deciced to make a new one so i wont update if there any mistakes