Connection isn't deconnecting (Maids)

I fixed it up for you For Eternalove_fan32.rbxl (25.9 KB)

main_large

btw if you open up the output it’ll print your current health (rounded).
Oh, and merry christmas!

Thanks! Leave me give this a try, I was about to fix it myself, but a bit of help dosen’t hurts. Merry Christmas too!

(P.S.: Oh, the Vanilla icons are too good, I need them myself)

Ehm, I just forgot to say that I solved it, only that I forgot to deconnect the event at the end and to use maids.

The icons work on VS Code too!

1 Like

Well, to solve it I played around with normal brickparts, then I tried to watch what was wrong in my code, I filtred out some parts and polished a little bit my code. Now (without maids and event deconnecting) it looks like this:

	for _,Part in ipairs(workspace.Golem:GetChildren())do
		if not Part:IsA("BasePart") then continue end
		Part.Touched:Connect(function(hitpart) --If some part touches something
			if not hitpart:IsDescendantOf(workspace.Golem) and hitpart.Parent:IsA("Model") then
				local Test = Part
				if not debounce then --If the player wasn't attacked (Else it will spam attack the player)
					if hitpart.Parent:FindFirstChild("Humanoid") then --Control if the hitted Instance has a humanoid object
						print("Attack")
						debounce = true
						hitpart.Parent.Humanoid:TakeDamage(10) --If yes, it's a player and damage it
						Humanoid:MoveTo(HRP.Position)
					end
				end
			end
		end)
	end

And with maids:

	local maidClass = Maid.new()

	local function GolemnHit(hitPart)
		if not hitPart:IsDescendantOf(workspace.Golem) and hitPart.Parent:IsA("Model") then
			if not debounce and hitPart.Parent:FindFirstChild("Humanoid") then
				print("Attack")
				debounce = true
				hitPart.Parent.Humanoid:TakeDamage(10) --If yes, it's a player and damage it
				Humanoid:MoveTo(HRP.Position)
				maidClass:DoCleaning() 
			end
		end
	end

	for _,Part in ipairs(Golem:GetChildren()) do 
		if not Part:IsA("BasePart") then continue end
		print("Task given")
		maidClass:GiveTask(Part.Touched:Connect(GolemnHit))
	end

Now, I just need to integrate maids, But because you tried to help me I will mark it as solved. Thanks to all the others too!

What plugin do you used? Just asking this out of curiosity (It’s better PM because it else goes off topic)

1 Like

For the icons? Just vscode-icons

1 Like