If i remove 'or "Barrier"' it works but when i add it everything is setting the script off.
local enabled = true function onTouched(hit) if enabled == true and hit.Name == "Object" or "Barrier" then enabled = false script.Parent.Particles.Rate = 250 local Copy = script.Particles:Clone() Copy.Parent = hit Copy.Remover.Disabled = false wait(0.3) script.Parent.Particles.Rate = 0 enabled = true end end Connection = script.Parent.Touched:Connect(onTouched)
Yes you are. When you use or
it is like you are creating an entirely new if statement(not quite, but close). Because strings "" evaluate to truthy in Lua your if statement will always pass because "Barrier" evaluates to true. What you need to do is have another hit.Name==
after the or
like so:
if hit.Name == "Object" or hit.Name == "Barrier" then -- code end
Now the only things that will pass through the if statement are things named "Object" and things named "Barrier". I hope this helped, but if it did not then feel free to post a question in the comments below. Have a great day scripting!