Healing Script not working

tool.Activated:Connect(function()
	if  healingDebounce then
		return
	end
	healingDebounce = true
	
	local healingSound = createSound(tool.Handle, properties.HealingSoundProperties)
	healingSound:Play()
	healingSound.Ended:Connect(function()
		healingSound:Destroy()
	end)
	task.wait(properties.AnimationDuration)
	if tool.Parent.Name ~= "Backpack" then
		tool.Parent.Humanoid.Health += properties.HealingAmount
	else
		healingDebounce = false
		return
	end
	
	if not properties.OneUse then
		task.wait(properties.HealingCooldown)
		healingDebounce = false
	else
		tool:Destroy()
	end
end)

Interested in why this code won’t work. The purpose is that it looks for when my tool is activated and then plays a sound, waits for something else in my module script and then also heals the player but it doesnt seem to do it. Why?

Did you check output for any errors?

SoundID is not a valid member of Sound “Sound”

local function createSound(parent, soundProperties)
	local sound = Instance.new("Sound")
	for property, value in soundProperties do
		sound[property] = value
	end
	sound.Parent = parent
	return sound
end

In this ^^^^^^

  • post bump* Please I need help…

When you get this error, the next lines of code stop working as the whole tool.Activated function gets cancelled. What you will need to do is debug the createSound function, try removing or commenting out the whole sound creation process and see if the createSound function was the issue

Try this:

tool.Activated:Connect(function()
	if  healingDebounce then
		return
	end
	healingDebounce = true
	
	--[[
	local healingSound = createSound(tool.Handle, properties.HealingSoundProperties)
	healingSound:Play()
	healingSound.Ended:Connect(function()
		healingSound:Destroy()
	end)
	]]--
	task.wait(properties.AnimationDuration)
	if tool.Parent.Name ~= "Backpack" then
		tool.Parent.Humanoid.Health += properties.HealingAmount
	else
		healingDebounce = false
		return
	end
	
	if not properties.OneUse then
		task.wait(properties.HealingCooldown)
		healingDebounce = false
	else
		tool:Destroy()
	end
end)