How do i make a tool that heals every second and plays animation and an audio when pressing left click

  1. What do you want to achieve? Keep it simple and clear! (I want to make a medkit that plays an animation and sound and it also heals the player every second)

  2. What is the issue? Include screenshots / videos if possible! (I have no idea on how to make the function)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? (ive tried making the script that heals every 1 second but didnt succeed, ive tried deugging the script too and it turns out it really didnt work)

healing script :

local tool = script.Parent
local Character = tool.Parent
local humanoid = Character:WaitForChild('Humanoid')

tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		while wait(1) do
		    Character.humanoid.Health = Character.humanoid.Health + 5
		end
	end)
end)

i have no idea on what im even making

you can make a function that plays when you hold left click, and you have your thing equipped

then put it in a while loop, and when you let go of left click, it exits out of the function

2 Likes
local tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character

tool.Activated:Connect(function()
    if Healing == false then
       Healing = true
       repeat wait(1)  Character:WaitForChild("Humanoid").Health += 5 until Character:WaitForChild("Humanoid").Health >= Humanoid.MaxHealth
       print("Fully Healed Player")
       Healing = false
    end
end)

This should be A LocalScript in the tool.
Once you Click with the Tool, It will Start Healing the Player Until Player is on Full Health.

If you want the Player to Heal Only Once,
Then Do

local tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character

tool.Activated:Connect(function()
    if Healing == false then
       Healing = true
       Character:WaitForChild("Humanoid").Health += 5 
       tool:Destroy() -- Removes Tool Once Used
       Healing = false
    end
end)
2 Likes

I’m not sure your supposed to give him a whole script, and also the script only heals, not anything else he asked for.

(but don’t redo the script lol, you’re not supposed to do the whole thing for him)

2 Likes

Do i need to define the Healing?

Oh yea,

Just on the First line do

local Healing = false
1 Like