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

Touched not working?

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

✓ Accepted answer

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)

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