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

How can I go through my whole table for my script?

Asked by 9 years ago

I know how I can do my script without a table, but that just seem like too much. I'm not sure if I need to do something like- for i,v in pairs (Parts) do ... and so on. I'd like an explanation if there's another way too! Here's the script:

sp = script.Parent
Parts = {"Part","Wedge","Truss","Brick","part","CornerWedge"}


sp.Touched:connect(function(hit)
    if hit.Name == Parts then
        hit.BackSurface = "SmoothNoOutlines"
        wait()
        hit.BottomSurface = "SmoothNoOutlines"
        wait()
        hit.FrontSurface = "SmoothNoOutlines"
        wait()
        hit.LeftSurface = "SmoothNoOutlines"
        wait()
        hit.RightSurface = "SmoothNoOutlines"
        wait()
        hit.TopSurface = "SmoothNoOutlines"
    else
        print("Condition is Not Met")
    end
end)
0
I'm just simply confused a bit on this, Lol. I assume I didn't do it right due to every touch, I get the else part of my script fired. alphawolvess 1784 — 9y
0
You probably want to use `if hit:IsA("BasePart") then` if you mean to check if `hit` is some sort of part (it has the Surface properties) though that will always be true for the `Touched` event. BlueTaslem 18071 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

sp = script.Parent Parts = {"Part","Wedge","Truss","Brick","part","CornerWedge"} for i,v in pairs(Parts) do sp.Touched:connect(function(Hit) if Hit == v then --do something end end
0
I'll accept even though you have problems with that script but I can fix. alphawolvess 1784 — 9y
0
And your forgot to make it Hit.Name == v then ....etc alphawolvess 1784 — 9y
0
So sorry. raspyjessie 117 — 9y
Ad

Answer this question