I made a bandage tool
It works perfectly but after reseting it says in output
Infinite yield possible on 'Workspace.razvanbosbos3456:WaitForChild(“Humanoid”) and then cannot use the tool
Here is the script:
local Animation = game.ReplicatedStorage.Animations.Support:WaitForChild("Bandage")
local PLR = game.Players.LocalPlayer
local Char = workspace:WaitForChild(PLR.Name)
local WalkScript = script.Parent:WaitForChild("ForceWalkSpeed")
local HUM = Char:WaitForChild("Humanoid")
local Timer = 2.1
local Tool = script.Parent
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://5020631118"
local UIS = game:GetService("UserInputService")
local Debounce = false
local Healing = 0
Tool.Equipped:Connect(function()
Equipped = true
end)
Tool.Unequipped:Connect(function()
Equipped = false
end)
local Used = false
UIS.InputBegan:Connect(function(Input, GPE)
if GPE or not Equipped then
return
end
if Input.UserInputType == Enum.UserInputType.MouseButton1 and not Debounce then
local LoadedAnimation = HUM:LoadAnimation(Animation)
local Sound = Instance.new("Sound")
local HeartEffectCloned = game.ReplicatedStorage.Particles.Support.EmitHealVFX:Clone()
WalkScript.Enabled = true
Used = true
Sound.SoundId = "rbxassetid://5020631118"
Debounce = true
HUM.AutoRotate = false
local Root = Char:WaitForChild("HumanoidRootPart")
LoadedAnimation:Play()
task.wait(Timer + .3)
Sound:Play()
HeartEffectCloned.Parent = Char.PrimaryPart
HeartEffectCloned.Position = Char.PrimaryPart.Position
for i,v in pairs(HeartEffectCloned:GetDescendants()) do
if v:IsA("ParticleEmitter") then
task.spawn(function()
v:Emit(v.Rate)
end)
end
end
Sound.Parent = Char.PrimaryPart
HUM.Health = HUM.Health + 25
Used = false
WalkScript.Enabled = false
HUM.WalkSpeed = 12
print(HUM.Health)
HUM.AutoRotate = true
task.wait(3)
Sound:Destroy()
HeartEffectCloned:Destroy()
Debounce = false
end
end)
HUM.Died:Connect(function()
Tool:Destroy()
end)