Sword not doing damage to a brick with a humanoid + not updating text

Still damages things but it doesn’t work.

1 Like

if humanoid and humanoid.Health ~= 0 then

Do you have the 0 instead of “nil”? Because I made a small mistake and maybe you copied it wrong.

Yeah but that doesn’t change the fact that it doesn’t damage it.

1 Like

I have the solution! The Humanoid Must be inside a model. Put the Part and the Humanoid in the same model.
Hope this works, I am not 100% sure.

2 Likes

Would the humanoid be inside the part still or would it be just inside the model?

1 Like

Inside the model, if this doesn’t work I will try to remake the scripts.

It works now! Thank you so much!

No problem! I am glad it worked! Make sure you make that answer the solution.

Also, is there a way to make that a bar? Like instead of using text you can make it like a progress bar but it goes down.

You could insert a progress bar, insert a script inside it. And in the script you divide the health by maxHealth and round it up.

I’ve never used it so I do not understand a word about what you’re saying.

First, you create a progress bar. Then you do some math:

local frame = script.Parent
local bricc = workspace.brickgod
local human = bricc.Humanoid

while true do
   frame.Size = UDim2.new(math.floor((bricc.Humanoid.Health) / (bricc.Humanoid.MaxHealth)),0,1,0)
end

That would be a health bar basically, YT is full of tutorials but I can show you a small script here.

A useful tutorial.

local HPBar = script.Parent.Parent:FindFirstChild("HPBarName")
local Brick = workspace:FindFirstChild("brickgod")
local Human = Brick:FindFirstChild("Humanoid")

Human.HealthChanged:Connect(function()
     local Percent = Human.Health / Human.MaxHealth * HPBar.Size.X.Offset
     HPBar.Size = Udim2.new(0, Percent, 0, HPBar.Size.Y.Offset)
end)
1 Like

You will have to make your own HealthBar Frame

1 Like

Your while true do loop would break someone’s studio, remember to add a wait() !

2 Likes

It automatically disabled it after the max executions if you don’t add wait()

1 Like

Oh well, I forgot about that fact. But you get what I was saying.

1 Like

That tutorial is for a player type one so I don’t think I’ll bother with it because I don’t know to to change it.

1 Like

Is there is a localscript? Inside the GUI?

2 Likes

It’s all solved like an hour ago…

3 Likes