How to make a good push button?

I am trying to make a button where something can push it and it activates (like one from portal). This object can be anything from a player to a box.

I have tried using a spring constraint but I couldn’t find the right values for the block to stay up without anything (also .Massless did nothing) and go down when something was on it.
I have also tried .Touched but pressing the button didn’t feel that polished.

1 Like

Make a hitbox, which is just a bit above the button, then use :Lerp to smoothly move it up/down.

Then detect .Touched on the hitbox, then put them into an array or dictionary. Then Once they leave the hitbox remove them from the table and once the table does not have more than 1 touching it’ll go back up.

-- Inside the TouchEnded
-- Verify if it can move the button up/down
-- Check if the value is in the table
-- Remove the value from the table

if #touching <= 0 then 
   -- go back down
end
1 Like

Good idea but I would really like the button pressing to primarily use the roblox physics engine.

1 Like

Sure that is possible, but roblox’s physics are not very reliable. It could get stuck etc.
If you do use it use a PrimsConstraint to allow it only to move up/down and to constraint it from going further and using a spring, though it would be harder to detect if you would only use roblox’s physics.

I am trying to use the spring but for some reason the button is bouncing up and down, anyway to stop that.

As I said a PrismConstraint could fix that, you’d can first limit the Z, X direction so it does not bug out then you can limit the rotation so that it does not rotate and lastely you can limit the Y, so that it can only move so much up and so much down.

Oh yeah you’ll need to turn this on:
image