I’m trying to make it so, if they hold the Prompt, the player’s “GHeal
” attribute is increased by 0.05 per second and the HoldDuration
to be automatically updated inversely based on the GHeal
, for example if GHeal
is 1, The HoldDuration
is 0, If GHeal
is 0, HoldDuration
is 20 (which is the max duration), if GHeal
is 0.5, Duration is 10, and so on…
The code generally works, but the issue is, if the prompt is still shown, the HoldDuration
doesnt update, only if i disappear the Prompt and repear it, it updates. I want the HoldDuration
to update everytime they hold, so even if the prompt is shown to player, the HoldDuration
smoothly updates.
Based on my experience it seems like a roblox proximity prompt issue, but I ain’t blaming it fully yet, it could just me being dumb but idk. If it is the case, are there any alternatives, like do I have to redesign a custom proximity prompt system?
function GlobalHeal:LoadPromptToChar(player: Player)
if player.Character then
local HumanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
local Prompt = script.Parent:FindFirstChild("HealingPrompt")
local P = Prompt:Clone()
P.Enabled = false
P.Parent = HumanoidRootPart
local isHold = false
P.PromptButtonHoldBegan:Connect(function(healer)
print("Hi")
local duration = (1-player:GetAttribute("GHeal")) * 20
P.HoldDuration = duration
isHold = true
while isHold do
print("hi")
local g = player:GetAttribute("GHeal")
player:SetAttribute("GHeal", g+0.05)
task.wait(1)
end
end)
P.PromptButtonHoldEnded:Connect(function(healer)
isHold = false
end)
end
end