Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

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.

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.

1 answer

✓ Accepted answer

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

3 comments

0

I'll accept even though you have problems with that script but I can fix.

0

And your forgot to make it Hit.Name == v then ....etc

0

So sorry.

This discussion is preserved as it was. New answers, comments, and votes are closed.