Also does the train have a humanoid? I see you’re checking for a humanoid in the touch event.
Touched events DO NOT fire when both of the parts experiencing the event are .Anchored
. Period. I’ve experienced it in my own games, my own experience, and Roblox itself says it in the article. Read it before you talk.
Oh, you mean both parts being anchored. Then yeah.
So aggressive lol.
No… There is no humanoid oof. Sorry.
You should check before you make claims like that, not to be rude or anything.
Check for something else like
local deb = false
local Signal1 = script.Parent.SignalParts.Red
local Signal2 = script.Parent.SignalParts.Yellow
local Signal3 = script.Parent.SignalParts.Green
Touch.Touched:Connect(function(Hit)
if not deb then
deb = true
local thing = Hit.Parent:FindFirstChild(YOUR_THING_HERE)
if thing then
Signal1.Material = Enum.Material.Neon
Signal2.Material = Enum.Material.SmoothPlastic
Signal3.Material = Enum.Material.SmoothPlastic
wait(60)
Signal1.Material = Enum.Material.SmoothPlastic
Signal2.Material = Enum.Material.Neon
Signal3.Material = Enum.Material.SmoothPlastic
wait(30)
Signal1.Material = Enum.Material.SmoothPlastic
Signal2.Material = Enum.Material.SmoothPlastic
Signal3.Material = Enum.Material.Neon
end
deb = false
end
end)
Replace “YOUR_THING_HERE” with a part of the train.
Ex. Wheels, Tank engine
It worked. Can you explain how it goes? I want to know about lua more.
This is exactly what i’ve been saying. Simply use this method, or any other method that doesn’t rely on the existents of another part. Like raycasting in a specific direction. If part the intersect the ray is a descendant of the train, You can run the code.
Yeah sure,
So instead of checking for a humanoid, which the train has none of, we check for a train exclusive part. Like a wheel or a section. Not everyday you see a player with wheels right?
I don’t recommend this method. A good practice in programming would be to make your code reusable as possible. Of course, it’s fine if it’s the only “train” in the game, but if there are multiple trains, there could be a possibility that there won’t be THAT specific part in another train.
Thank you so much!! Really nice.
Just rename the trains to unique names or attributes lol. Simple fix.
Also pretty sure all the trains would behave the same way in this case.
I know, that’s what I was going to suggest, lol.
Oh. I will try to learn more as I can.
if train:GetAttribute("IsTrain") then
-- code here
end
Okay. I will try that too. But first I will search about GetAttribute.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.