How can I make a controlled jump height script?

local uis = game.UserInputService
local InputEnd = false


InputBegan:Connect(function()
     InputEnd = false
     repeat wait() JumpHeight += 1 until InputEnd or JumpHeight == MaxJumpHeaight
end)

InputEnded:Connect(function()
     InputEnd = true
end)

something basic like this