Lift type script

Hello there, I am trying to make a script to where you click a button and it will bring a lift up
As of now so far I’ve got it working with the lift going up. But my current issue is that when the
lift goes down it seems to go down under the baseplate. I have tried a few method but it seemed to not work.

New Video (edit)(
https://medal.tv/games/roblox-studio/clips/e2O8lPFpvQv3D/d1337N3YXsUj?invite=cr-MSxKb1osMjA1NDY2NCw

local sphere = script.Parent
local Rope = workspace.Rope
local RopePart = workspace.RopePart
local spincount = 1
local debounce = false
local redBlock = game.Workspace.Platforem
local waitvalue = false
function onClicked()
if waitvalue == false then
waitvalue = true
if debounce == false then
debounce = true
repeat
redBlock.CFrame = CFrame.new(redBlock.Position) + Vector3.new(0, 0.1, 0)
sphere.Rotation = Vector3.new(0,0,spincount)
Rope.Rotation = Vector3.new(0,0,spincount)
RopePart.Rotation = Vector3.new(0,0,spincount)
wait(0.02)
spincount = spincount + 1
until spincount >= 250-- 10 = 1 second
else
debounce = false
repeat
redBlock.CFrame = CFrame.new(redBlock.Position) - Vector3.new(0, 0.1, 0)
sphere.Rotation = Vector3.new(0,0,spincount)
Rope.Rotation = Vector3.new(0,0,spincount)
RopePart.Rotation = Vector3.new(0,0,spincount)
wait(0.02)
spincount = spincount - 1
until spincount >= 250-- 10 = 1 second
end
waitvalue = false
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)