I am making a button that whenever a player touches it with any of the both legs the button will go down 2 studs to give it a little effect, but I don't know where the problem is!
There's an activator part which has the script in it and it will cause the button go down 2 studs
part = script.Parent button = script.Parent.Parent.Button.Button part.Touched:connect(function(hit) if hit.Name == "Left Leg" or "Right Leg" then button.Position.Y = button.Position.Y - 2 end end)
GeezuzFusion's answer is correct.
There is another problem with your code.
hit.Name == "Left Leg" or "Right Leg"
does not mean what you think it does.
The actual order of operations is this: (hit.Name == "Left Leg") or "Right Leg"
You compare the name to "Left Leg", and otherwise get "Right Leg". That means you'll always proceed.
You must explicitly make each comparison:
if hit.Name == "Left Leg" or hit.Name == "Right Leg" then
You can't Assign and process arithmetic values to a variable individually (ex: X, Y, Z). You have to use a Vector3 value or a CFrame Value.
part = script.Parent button = script.Parent -- I Changed this to test it. part.Touched:connect(function(hit) local x, y, z = button.Position.X, button.Position.Y, button.Position.Z -- Assign Each Value if hit.Name == "Left Leg" or "Right Leg" then button.CFrame = CFrame.new(x, y - 2 ,z) -- This is how you should apply arithmetic. end end)
This should work.