heres the code
local y = script.Parent.CFrame.Y
local part = script.Parent
local button = workspace.Button2.button2.scriptpart2
local e = 1
button.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
repeat wait() until button.Touched
while true do
part.CFrame = CFrame.new(36, y + 0.05 * e, -36)
wait(0.05)
print("height is" and y)
print(script.Parent.CFrame.Y)
if y > 20 or y < 3 then
print('We have triggered')
e = e * -1
wait(3)
end
end
end
end
)

2 comments
Try using BodyPositions
But in this case turn off cancollide