Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my dummy:Destroy destroys the HumanoidRootPart HumanoidRootPart not valid member of Model "Dummy1" ?

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

0

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.

0

how to check if the humanoidrootpart is an actual child of the instance? and thanks

0

you can use the explorer tab

0

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

0

*it

0

You're finding a child of the game called "HumanoidRootPart", you should do dummy:FindFirstChild("HumanoidRootPart) and use dummay:Destroy() instead of dummy:Destroy()

0

i tryed it but i doesn't work

0

*it

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.