Stat Boost Script Not Working

Hello everyone!
I’m making a Tower Defense game and I’m trying to make a tower that would scream and boost every ally’s stats that are in a certain hitbox part

The script doesn’t seem to work however.
It only prints: “boosted stats” which is according to the script, but the rest of the script won’t work

this is the script:

local db = false
wait(10)
print("boosted stats")
script.Parent.hitbox.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("isally") then
		if hit.Parent:FindFirstChild("damage") then
			if db == false then
				db = true
				script.Parent.scream:Play()
				hit.Parent.damage.Value = hit.Parent.damage.Value * 2
				wait(20)
				hit.Parent.damage.Value = hit.Parent.damage.Value / 2
				db = false
			end	
		end
	end
end)

I need help.

1 Like

Touched is very inconsistent with detection and the problem right now is that it’s most likely not detecting anything in the part that isn’t moving. I recommend using the ZonePlus v2 module, one way you can do this is you using use the getParts function from that module to see if the part in a zone’s parent is an ally and boosting them from there.

1 Like

So you mean that parts can’t be detected unless they move inside the hitbox?

If you’re using the Touched event then yes that is generally how it works based off when I used it.

1 Like

thank you.
i have one more question, i don’t quite understand that module you sent me. judging by what i saw, there were only player detections. are there any normal entities detections? (for example a sniper)

Nevermind! I got it. I checked the inside of the Zone module script and there was this part:

zone.partEntered:Connect(function(part)
    print(("part '%s' entered the zone!"):format(part.Name))
end)

sooo yep. thank you anyways, this helped me a lot :smiley:

1 Like