Hello,
The problem I’ve been running into is that I can’t seem to get this Proximity Prompt to work.
The way it’s supposed to work is so that when the player is low on health, they can hold “E” and regenerate the health back.
CODE:
local Part = script.Parent
local Prompt = Part.ProximityPrompt
--
local Values = workspace.Values
local HealingValue = Values.Healing
--
Prompt.PromptButtonHoldBegan:Connect(function(player)
--
HealingValue.Value = true
local Character = player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
--
if Humanoid.Health ~= 100 then
--
while Humanoid.Health ~= 100 do
--
wait(1)
if HealingValue.Value == true then
--
Humanoid.Health = Humanoid.Health + 4
--
elseif HealingValue.Value == false then
break
end
--
end
else
--
end
end)
--
Prompt.PromptButtonHoldEnded:Connect(function(player)
--
HealingValue.Value = false
--
end)
Prompt.Triggered:Connect(function(p)
local Chr = p.Character
local Hmd = Character:FindFirstChild("Humanoid")
if Hmd.Health < Hum.MaxHealth then
Humanoid.Health = Humanoid.Health + 4
else
warn("Already At Max Health!")
end
end)
local IsHolding = false
script.Parent.PromptButtonHoldBegan:Connect(function(p)
local Chr = p.Character
local hmd = Chr:FindFirstChildOfClass("Humanoid")
IsHolding = true
script.Parent.PromptButtonHoldEnded:Connect(function(p)
IsHolding = false
end)
while IsHolding == true do
wait(1)
if hmd.Health < hmd.MaxHealth then
hmd.Health += 4
else
warn("Already Full")
end
end
end)