The title might not make sense, but I’ll explain it. Basically I have this custom Prompt UI for my game, and there’s this drawer that needs moving
The meter I have has 5 stages, one for each second it is pulled.
Now, for each stage the drawer is pulled, it decrements one from the meter
SCRIPT (mixed with pseudo-code)
prompt.holding:Connect(function()
local stat = false
prompt.holdend:Connect(function() --only wrote 'holdend' to not waste time
stat = true
prompt.holdduration = meter
end)
repeat
meter-=1
task.wait(1)
until stat
end)
It works well, perfectly you could say. The only issue is the Tween from the Prompt UI I have not updating each time the player doesn’t hold the prompt (only when I keep looking at it/still visible)
VIDEO 1 (From leaving the prompt then coming back)
VIDEO 2 (Prompt still in range/visible)
I know the problem lies under the code for the custom UI (keep in mind it’s a free model, although it works really well).
--Custom UI, in LocalScript
local AnimeTweenInfo = TweenInfo.new(prompt.HoldDuration, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
The question is, how do I make it so that the HoldDuration updates the TweenNumber of the prompt TweenInfo?
TLDR; Meter/HoldDuration goes down, but TweenNumber from Custom Prompt UI doesn’t. Both update at the same time, with the same values. How can I keep updating HoldDuration so that when a player stops holding a prompt, TweenNumber == currentHD (HoldDuration)?
The variables only update when the prompt has first been shown to the player.
In the free model you sent to me, open the “CustomPrompt” local script and head to line 317.
you should find a PromptButtonHoldBegan function there.
at the start of that function, add:
-- we are redefining the tween info to get the new HoldDuration
AnimeTweenInfo = TweenInfo.new(prompt.HoldDuration,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out)
HoldTween1 = TweenService:Create(ProgressFrame, AnimeTweenInfo,
{Size = InputFrame.Size})
it should look like this:
prompt.PromptButtonHoldBegan:Connect(function()
-- we are redefining the tween info to get the new HoldDuration
AnimeTweenInfo = TweenInfo.new(prompt.HoldDuration,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out)
HoldTween1 = TweenService:Create(ProgressFrame, AnimeTweenInfo,
{Size = InputFrame.Size})
loop = true
AnimeRoutean = coroutine.create(HoldAnimation)
coroutine.resume(AnimeRoutean)
-- hide all but the key button
for _, tween in ipairs(tweensForFadeOut) do tween:Play() end
end)
The TweenInfo variables will now change when the prompt starts to be held to account for a changed HoldDuration. I hope I understand stood your issue correctly and that my changes fix it.
sorry for taking a long time to respond. i actually forgot about this post. sorry about that.