Having to drop a medkit each time I want to use it

  1. I want to be able to use the medkits without having to drop them and pick them back up

When using them, I can pick them up, and I can use the first one in sucession, but if I equip a different one I have to drop all of the ones in my inventory, pick them up and use one again for it to work, and repeat each time

I tried fixing it with moving how the server finds it, using firing events but I can only make it work once without having to drop all of them, and if I start with them in my starter pack I have to drop all them and pick it up

This is the script inside of the tool

local Players = game:GetService("Players")
local remote = game.ReplicatedStorage:WaitForChild("UseMedkitEvent")

local tool = script.Parent
tool.Activated:Connect(function()
    remote:FireServer(tool)
end)

This is the script inside of serverscriptstorage

local remote = game.ReplicatedStorage:WaitForChild("UseMedkitEvent")
local MAX_INJURY = 5

remote.OnServerEvent:Connect(function(player, tool)
    local character = player.Character
    if not character then return end
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if not humanoid then return end

    local healAmount = tool:GetAttribute("HealAmount") or 100
    local injuryLoss = tool:GetAttribute("InjuryLoss") or 1

    humanoid.Health = math.min(humanoid.MaxHealth, humanoid.Health + healAmount)

    local injuryValue = player:FindFirstChild("Injury")
    if not injuryValue then
        injuryValue = Instance.new("NumberValue")
        injuryValue.Name = "Injury"
        injuryValue.Value = 2
        injuryValue.Parent = player
    end
    injuryValue.Value = math.clamp(injuryValue.Value - injuryLoss, 0, MAX_INJURY)

    print(player.Name .. " healed by " .. healAmount)
    print("New Health: " .. humanoid.Health)
    print("New Injury Level: " .. injuryValue.Value)

    tool:Destroy()
end)

Inside of each tool there is two attributes, a “InjuryLoss” and “HealAmount” Injury loss showing the injury loss it losses and Healamount showing how much health you gain

1 Like


This is a better video showing both clients

For now, try setting humanoid.Health to 100 and see if it works. If not, then there’s an issue with the attributes.

yeah I blocks where it sets health to 100, 95, 50, 10, 0 and they all work with shooting etc

Found out a way to do it, don’t know if its performance good but it works nethertheless

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.