local Part = script.Parent --whatever
local Front = Part.Position + Part.CFrame.LookVector
local Back = Part.Position - Part.CFrame.LookVector
TrackSpeed = script.Parent.Values.Speed
function OnTouch(hit)
if (hit.Position - Front).magnitude < (hit.Position - Back).magnitude and hit.Name == 'TrainTrigger' then
if hit.Chassis.Value == "Basic" then
hit.Parent.Parent.Parent.Values.Speed.Value = TrackSpeed.Value
print(string.format("Speed requested to be changed to %s", TrackSpeed.Value))
elseif hit.Chassis.Value == "Advanced" then
hit.Parent.Parent.Values.Speed.Value = TrackSpeed.Value
print(string.format("Speed requested to be changed to %s", TrackSpeed.Value))
end
end
end
script.Parent.Touched:connect(OnTouch)
Is there a way to get this to look at the value of the NumberValue everytime the function is ran?
I'm trying to get this sensor working to where when a train runs over the sensor, the speed limit shown in a GUI in the cab gets changed to whatever Speed is set at

1 comment
is this normal or local script?