i have 2 variables Progress
and percentageValue
. progress is 0-1 (representing 0-100%) and percentage value which is also the same thing more less.
my issue is that even after the hold duration has finished for the prompt, it’s meant to print 1 for progress and 100 for percentagevalue. it’s printing something around 98-99 ish when it has completed.
i appreciate any help ty!!
output:
video:
local function buttonholdBegan(p)
print("started holding")
startTime = tick()
promptCompleted = false
local function updatePercentageHeld()
local elapsedTime = tick() - startTime
local Progress = math.clamp(elapsedTime / TWEEN_TIME, 0, 1) --0 to 100%
local percentageValue = math.floor(Progress * 100)
percentage.Value = percentageValue
print("percentageValue: "..percentageValue)
print("Progress: "..Progress)
if Progress >= 1 then
promptCompleted = true
percentage.Value = 0
resetGradients(left_grad, right_grad)
connection:Disconnect()
end
right_grad.Rotation = math.clamp(Progress * 360, 0, 180)
right_grad.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, PP_UI.holder.colorOfProgress.Value),
ColorSequenceKeypoint.new(0.5, PP_UI.holder.colorOfProgress.Value),
ColorSequenceKeypoint.new(0.501, PP_UI.holder.colorOfmissingPart.Value),
ColorSequenceKeypoint.new(1, PP_UI.holder.colorOfmissingPart.Value),
}
right_grad.Transparency = NumberSequence.new(0)
if Progress >= 0.5 then
local leftProgress = (Progress - 0.5) * 2
left_grad.Rotation = math.clamp(180 + (leftProgress * 180), 180, 360)
left_grad.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, PP_UI.holder.colorOfProgress.Value),
ColorSequenceKeypoint.new(0.5, PP_UI.holder.colorOfProgress.Value),
ColorSequenceKeypoint.new(0.501, PP_UI.holder.colorOfmissingPart.Value),
ColorSequenceKeypoint.new(1, PP_UI.holder.colorOfmissingPart.Value),
}
left_grad.Transparency = NumberSequence.new(0)
end
end
connection = rs.RenderStepped:Connect(updatePercentageHeld)
end
pp.PromptButtonHoldBegan:Connect(buttonholdBegan)