I've got a bug on my script on a healing item. Anyone can help?

I have an error on my healing item? Anyone got opinions on how to fix it?

My script:

local MAX_HEALTH = 100
local ENABLED_TRANSPARENCY = 0.4
local DISABLED_TRANSPARENCY = 0.9
local COOLDOWN = 20

local healthPickupsFolder = workspace:WaitForChild("HealthPickups") -- Variable for the folder.
local healthPickups = healthPickupsFolder:GetChildren() -- Variable for healthPickups

local function onTouchHealthPickup(otherPart, healthPickup) -- Function that checks that a object that touched is a character and haves a humanoid.
	local character = otherPart.Parent -- Variable for character.
	local humanoid = character:FindFirstChildWhichIsA("Humanoid") -- Humanoid Variable.
	if humanoid then -- If the object has a humanoid inside it, it will put the humanoid's health to the MAX_Health Varible.
		humanoid.Health = MAX_HEALTH
		healthPickup.Transparency = DISABLED_TRANSPARENCY
		healthPickup:SetAttribute("Enabled", false)
		wait(COOLDOWN)
		healthPickup.Transparency = ENABLED_TRANSPARENCY
		healthPickup:SetAttribute("Enabled", true)
	end
end

for _, healthPickup in ipairs(healthPickups) do -- Call the onTouchHealthPickups function, passing both the otherPart parameter and the healthPickup.
	healthPickup.Touched:Connect(function(otherPart)
		onTouch
HealthPickup(otherPart, healthPickup)
	end)

Welcome to Cookie Tech! :cookie:

Could you edit this post and highlight the code and then press the </>?
It might look like this
image

No, this will help us understand your code and error.

What’s the output when you run the script? And this time when you send your output please do this:

1 Like

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