i want the dummy(only the dummy) to be destroyed when it touches a block it's Lines(43)
wait(10)
local spawnTime = 5 -- the time in seconds
local spawnRate = 1 -- per spawn time
local pS = game:GetService("PhysicsService")
pS:CreateCollisionGroup("Minions")
pS:CollisionGroupSetCollidable("Minions", "Minions", false)
while script.Parent.Building.Health.Value > 0 do
wait(spawnTime)
for i = 1, spawnRate do
wait()
local dummy = game:GetService("ReplicatedStorage").Minions:GetChildren()[math.random(1, #game:GetService("ReplicatedStorage").Minions:GetChildren())]:Clone()
dummy.Parent = script.Parent.Minions
for i, v in pairs(dummy:GetChildren()) do
if v:IsA("MeshPart") or v:IsA("Part") then
pS:SetPartCollisionGroup(v, "Minions")
end
end
dummy.Humanoid.WalkSpeed = math.random(15, 16)
dummy.HumanoidRootPart.CFrame = script.Parent.Spawn.CFrame
local pFS = game:GetService("PathfindingService")
spawn(function()
for _, waypoints in pairs(script.Parent.Waypoints:GetChildren()) do
local path = pFS:CreatePath()
path:ComputeAsync(dummy.HumanoidRootPart.Position, waypoints.Position)
local wp = path:GetWaypoints()
for __, wp2 in pairs(wp) do
dummy.Humanoid:MoveTo(wp2.Position)
dummy.Humanoid.MoveToFinished:Wait()
end
end
end)
local dummay = game:FindFirstChild("HumanoidRootPart")
script.Parent.Building.Health.Value = script.Parent.Building.Health.Value - math.random(1, 10)
dummy:Destroy()
end
end
Thank you :)

8 comments
your script doesn't destroy the humanoidrootpart, just the dummy, but try to make sure that humanoidrootpart is an actual child of the instance you're destroying it from.
how to check if the humanoidrootpart is an actual child of the instance? and thanks
you can use the explorer tab
i check it says it's there but when i try to see if the script works it says "HumanoidRootPart not valid member of Model "Dummy1" but when i remove the dummy:Destroy i doesn't say it anymore
*it
You're finding a child of the game called "HumanoidRootPart", you should do dummy:FindFirstChild("HumanoidRootPart) and use dummay:Destroy() instead of dummy:Destroy()
i tryed it but i doesn't work
*it