I am trying to make walls which will be attacked by monsters and then upon 0 health break apart.
I read up on the roblox humanoid reference and i created the wall, making sure to name 1 part : Head 1 part : Torso and 1 part : HumanoidRootPart.
I can see it has health now but i am not sure if it is working. I tried to make the health 0 but it doesn’t break into pieces despite choosing break joints on death. The whole structure just remains with health 0.
As it is controlled by a singular value, you can compromise instead and use a IntValue that represents its health. You can script the functionality of breaking on the IntValue reaching 0.
Humanoid performance cost isn’t worth a wall that will only use the health property.
You should use an int value or something as health for the wall instead of a humanoid since it would be a waste of a humanoid to just use the health property like ArtFoundation said. You could have a simple script like
if script.Parent.Health.Value <= 0 then
script.Parent:Destroy()
--or if you wanted to keep the wall you could just
script.Parent.CanCollide = false
script.Parent.Transparency = 1
end
i mean, no the humanoid can be inside anything. although, using the methods @kom297 and @ArtFoundation said will be more efficient, this script should work if you have zombies damaging the wall already.
If you want a basic way to do a “humanoid wall” simply use intvalues. Also, if you’re looking for a wall that will break with an explosion, do this along with a raycast for a better way
while wait(1) do
local hitraycast = Ray.new(--First tuple is humanoid, -- second tuple is direction)
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(hitraycast, {-- put in what you want to ignore} ) -- not depreacted
end
if hit then
game.Workspace.Wall.Health --[[IntValue]] = game.Workspace.Wall.Health - 10
if game.Workspace.Wall.Health < 0 then
local explosion = Instance.new("Explosion")
explosion.Visible = false
explosion.Position = game.Workspace.Wall.Position
wait()
explosion.Visible = true
game.Workspace.Wall:Destroy()
end
end