Hello, I have a problem with my train track debounce and don't know how to get round it so I came here to see if anyone could help.
So, I have two pieces of track and I have joined them together as so http://prntscr.com/817eoq What I'm aiming to do is to be able to get then pieces of track which have a slight transparency on them(http://prntscr.com/817f1w) to move when 'Train1' travels over the red detector(http://prntscr.com/817f99). I have managed to get the track working where the transparencies and cancollides change so the train can drive but, I noticed that in game players are able to walk over these detectors and move the track. The aim was to make it so the train could do that and nothing else and I tried to figure out a way to fix this problem and couldn't.
Here is the current script which I have in the train engineF(forward) so when the part touches the detector the tracks switch :- http://prntscr.com/817gm7 I also had to add scripts to the detectors which look like so :- http://prntscr.com/817gwh
Detector script--------- local buttonPressed = false local debounce = true local hit = game.Workspace.Train.Chassis.EngineF
if hit.Parent.Parent.Name ~= "Train" then return
game.Workspace.Train.Chassis.EngineF.Touched:connect(function(hit) if not buttonPressed then
buttonPressed = true
if hit.Parent then game.Workspace.Rail1.Transparency = 1 game.Workspace.Rail1.CanCollide = false game.Workspace.Rail2.Transparency = 0 game.Workspace.Rail2.CanCollide = true
end wait(3)
buttonPressed = false end end)
EngineF script---------
local buttonPressed = false local debounce = true
game.Workspace.Detector.Touched:connect(function(hit) if not buttonPressed then
buttonPressed = true
if hit.Parent.Name ~= "Train" then return end
game.Workspace.Rail1.Transparency = 1 game.Workspace.Rail1.CanCollide = false
game.Workspace.Rail2.Transparency = 0
game.Workspace.Rail2.CanCollide = true
end wait(3)
buttonPressed = false end

8 comments
Should I put that in the Detector too?
Yeah, put it in the scripts with the detectors to make sure that a train is hitting it and nothing else. Just make sure the names match of the train model to that line.
http://prntscr.com/8189u0 http://prntscr.com/818a10 I have got confused, I've mixed up that much stuff together all day, I don't know how to do it :3 Would you be able to tell me pretty specifically?
Just from the looks both scripts seem kind of broken. Can you just copy and paste the whole scripts and make an edit to your post with those scripts in it?
Ok, edited it. The two scripts are in there.
What should I change them to, to get it working?
Edited the post above. Those should work
I messaged you on ROBLOX, it hasn't worked .