Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make it so Part A's touch script only runs when touched by a part w/specific name?

Asked by 2 years ago

Hi there, this is my 1st time here. So anyways, I've recently been trying to update signalling for my train game on ROBLOX, which is operated by touch scripts. I'm trying to make it so that it only detects certain parts so that it won't detect one's avatar or some other object. The only problem I have is that I'm pretty new to coding so it's difficult for me to figure out how to do that. I've tried the following codes from the DevForum when someone asked the same question as me:

part.Touched:Connect(function(other)
    print("Touched By:", other.Name)
    if other.Name == "SomePartName" then
        -- code
    end
end)


and

script.Parent.Touched:Connect(function(hit)

if hit.Parent.Name = “your name” then
–put stuff here

end

end)

None of those worked for me, and I can't post it myself on the DevForum, so I had to come here. Do you folks have any good tips on how I can update it for it to do that?

0
For more info regarding the scripts I tried, they were posted in May 2020. USABritishRailMan 0 — 2y
0
hey @usa i just read your question. I might be be to help you, but I just need some confirmations from you first. first, after you scripted this, did you test it? if you did, what were the results? and where did you keep this script in the explorer? extrorobo 104 — 2y
0
Yes, I did indeed test it, also trying by adding a line to print a message, and lo and behold, it didn't print. The developer console also showed nothing. The script is stored in a sensor part inside a folder, where, when executed, is supposed to parent its way out the sensor part, out the folder, into the Workspace, into the Signal folder, into the signal model, and change it's lights. USABritishRailMan 0 — 2y

Answer this question