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)
What is the issue? Include screenshots / videos if possible! (I have no idea on how to make the function)
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)
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)