Error when two Parameters are passed

Hello! I was following a tutorial for a health pickup when I encountered an error.

local MAX_HEALTH = 100
local healthPickupsFolder = workspace:WaitForChild("HealthPickups")
local healthPickups = healthPickupsFolder:GetChildren()

local function onTouchHealthPickup(otherPart, healthPickup)
	local character = otherPart.Parent
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		humanoid.Health = MAX_HEALTH
	end
end


for _, healthPickup in ipairs(healthPickups) do
	healthPickup.Touched:Connect(function(otherPart)
	onTouchHealthPickup(otherPart, healthPickup)
end

Here’s the error message:

  17:53:48.474  ServerScriptService.PickupManager:18: Expected ')' (to close '(' at line 15), got <eof>  -  Studio - PickupManager:18

I’m assuming the error has something to do with the second parameter or something related. Can anyone help me out?

Thanks

1 Like

Add another parenthesee to the final end in your script. You have to close the function and the parameters, not just the parameters.

like so?

onTouchHealthPickup(otherPart), healthPickup)

Is the error on that line? Or the line beneath it?

Syntax error here.

for _, healthPickup in ipairs(healthPickups) do
	healthPickup.Touched:Connect(function(otherPart)
	    onTouchHealthPickup(otherPart, healthPickup)
    end) -- end the connection function
end
2 Likes

it’s on the healthPickup param to the end.

Thank you for providing an example mate.

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