Cannot Use Tool after Reseting Character

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)
	

Where is this script located? The script is still running when there is no player as player died.

The script is located in the tool

I haven’t had much experience with tools yet but would tool.Activated:Connect(function()) work better then UIS? But anyway can you move all the player stuff down into the function? Then it only calls for the player after the player clicks?

SRY im pretty stupid I made a ragdoll after you die and it saved the player char and remained like that and since I used plr.Name it got the ragdolls humanoid and gitched
Works now

1 Like

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