The textlabel isn’t being updated like it should and it isn’t taking any damage either, even though I added a humanoid. Can someone help me? The scripts are:
update text label script:
local helth = script.Parent
local bricc = workspace.brickgod
local human = bricc.Humanoid
while true do
helth.Text = "bricc helth: " ..human.Health
wait(5)
end
damage script:
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid')
if humanoid then
humanoid:TakeDamage(10)
end
end)
The script inside the GUI. GUIs use LocalScripts to modify themselves.
Remember that LocalScripts affects the Client not the Server. That’s the reason, because GUIs work with a single client not with the whole server.
script.Parent.Touched:Connect(function(hit)
-- local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid') Instead of this try with FindFirstChild
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid.Health ~= 0 then
humanoid:TakeDamage(10)
end
end)
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