Potion stacking healing effects

When a player drinks a potion it heals them fine, but add another player that has the same potion in their inventory, and it doubles the healing effect for the person drinking the potion. For example, you have a healing potion that heals 50 health, if someone else has that potion you would then heal 100 health.

Local Script
local Player = game.Players.LocalPlayer
local Potion = script.Parent
local mouse = Player:GetMouse()
local c = Player.Character
local Enabled = true
Potion.Activated:Connect(function()
local Health = Player.Character.Humanoid.Health
local MaxHealth = Player.Character.Humanoid.MaxHealth
if Health >= MaxHealth then return end
if Enabled == true then
game.ReplicatedStorage.HealthPotion:FireServer(“FiftyHealthRecover”)
Enabled = false
local Track = Instance.new(“Animation”)
Track.AnimationId = “rbxassetid://7013765749”
local Anim = c.Humanoid:LoadAnimation(Track)
Anim:Play()
wait(0.5)
wait(1.0)
script.Parent:Destroy()
end
end)

Server Script

game.ReplicatedStorage.HealthPotion.OnServerEvent:Connect(function(Player,FiftyHealthHeal)
local Health = Player.Character.Humanoid.Health
local MaxHealth = Player.Character.Humanoid.MaxHealth
if FiftyHealthHeal == “FiftyHealthRecover” then
if Health >= MaxHealth then return end
if Player.Character.Humanoid.Health >= Player.Character.Humanoid.MaxHealth then return end
Player.Character.Humanoid.Health = Player.Character.Humanoid.Health + 50
end
end)

1 Like