Best way to damage anchored dummy

  1. What do you want to achieve? Keep it simple and clear!
    How to apply touchingParts or newer method WorldRoot:GetPartsInPart to have one anchored part damage an anchored dummy.
  1. What is the issue? Include screenshots / videos if possible!
    A power/skill in game makes a part appear and cause damage to npcs. But since its anchored it doesnt damage anchored dummies. Since the touched.connect doesnt work when both parts are anchored. Atleast without using touchingParts correctly.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried many variations of the 2 scripts posted but just cant get it working right.

Help is greatly appreciated on the matter!

local hit = true 
			NewSpike.Touched:Connect(function(Hit) 
				if hit == false then return end
				hit = false

				local char = Plr.Character
				if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= char.Name then

					Hit.Parent.Humanoid:TakeDamage(999)
					wait(2) 
					hit = true
				end
			end)
local char = Plr.Character
			NewSpike.Touched:Connect(function()

				local touchingParts = NewSpike:GetTouchingParts() --gets a table of touching parts
				for i, Hit in pairs(touchingParts) do -- loops through all the touching parts
					if Hit.Parent:FindFirstChild("Humanoid") then


						local ehum = Hit.Parent:FindFirstChild("Humanoid") 


						if not ehum.Parent:FindFirstChild("AlreadySpiked" .. char.Name) then

							local HitTag = Instance.new("BoolValue", ehum.Parent)
							HitTag.Name = "AlreadySpiked" .. char.Name
							HitTag.Parent = ehum.Parent
							game.Debris:AddItem(HitTag, 0.8)

							ehum:TakeDamage(999)
						end
					end
				end
			end)

Dummy on left is not anchored.
Dummies

You want to damage the Humanoid in the NPC, but it appears you are calling for the Humanoid in the Plr.Character, which is your player.


NewSpike.Touched:Connect(function()

local touchingParts = NewSpike:GetTouchingParts() --gets a table of touching parts
for i, Hit in pairs(touchingParts) do -- loops through all the touching parts
	--if Hit.Parent:FindFirstChild("Humanoid") then


		local enum = Hit.Parent:FindFirstChild("AlreadySpiked")


		if enum == nil then

			local HitTag = Instance.new("BoolValue")
			HitTag.Name = "AlreadySpiked"
			HitTag.Parent = enum
			game.Debris:AddItem(HitTag, 0.8)

			--here put you dummy humanoid
           game.Workspace.MyDummy.Humanoid:TakeDamage(999)
		end
	--end
end
end)

try this :slight_smile:

Both scripts damage non anchored npcs just not anchored ones.

Not working :confused: it does damage non anchored dummies though.

Can you choose one, please?

  1. One part can touch many dummies (but only one time each)
  2. One dummy can be hit by one part only

Can you explain what you’re trying to do?
In my understanding, you want to damage a dummy if a player stands on a part, with a debounce of 0.8 seconds?

For sure. It would have to be option 1.

--put this script inside your part
local part = script.Parent
local dummies = {}
part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("HumanoidRootPart") ~= nil then
		local was = false
		for i,v in pairs(dummies) do
			if v == hit.Parent.Humanoid then
				was = true
			end
		end
		if was == false then
			hit.Parent.Humanoid:TakeDamage(30)
			table.insert(dummies,hit.Parent.Humanoid)
		end
	end
end)

This one should work :slight_smile:

1 Like

I’ll post a gif. Basically its a power and the part (spikes) currently only damage non anchored dummies/npcs and need it to damage anchored ones as well.

I slightly changed my script, now it takes dmg to anchored, non anchored dummies. Remember to put it inside your part that makes dmg

So it still has same result. The dummy on left is not anchored while the other one is.
Dummies

Posted the gif so you can see what I mean. Thanks

Did you refresh my script? I edited it a few minutes ago

Yes, they did, as you can see the character taking 30 damage instead of the original 999 damage.

Yes, I used the latest script. The only thing I changed was local part = Newspike instead of script.parent as this is the part that gets cloned

I mean i edited my post where i had 30 dmg originally, now it’s still 30 dmg but it has one new line

To make sure, I copied and pasted it.

Hmm, it sounds weird. Do you have discord? I made it on my baseplate and it worked fine

Yes, my user is knatedawg#1813 but we probably have to be in a mutual server. You can find mine in my bio or if you share your server I can join as well.