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

Touched not working?

Asked by
theCJarmy7 1293 Moderation Voter
8 years ago
script.Parent.touch.Touched:connect(function(h)
    if h.Name == "stream1" or "stream2" or "stream3" or "stream4" or "stream5" or "stream6" or "stream7" or "stream8" or "stream9" then
        print("good")
        script.Parent.fill.Transparency = 0
        else print("bad")
    end
end)

a simple script, but it always prints good. no matter what i hit with the brick, it always prints good. is it because there are too many ors?

1 answer

Log in to vote
0
Answered by 8 years ago

You must ALWAYS put h.Name=="name". Otherwise, it will check if it's a string or something.. Idk, but it doesn't work.

Also, use a table to make things easier.

local stream={"stream1","stream2","stream3","stream4","stream5","stream6","stream7","stream8","stream9"}

script.Parent.touch.Touched:connect(function(h)
    for _,s in pairs(stream) do
        if s:lower()==h.Name:lower() then
            print'Good'
            script.Parent.fill.Transarency=0
            else
            print'Bad'
        end
    end
end)
Ad

Answer this question