I improved on the code from earlier today (it's not perfect) and now it's acting weird. When I touch all the bricks (meaning the "Health" should set to zero) it does not set to zero. I'm sure it's in my math somewhere but I cannot find where or how
Instead, it sets to 36.61%: Photo
My code (Please answer my question if you can, not ridiculing on how my code can be improved without explaining how :FrowningFace: )
local debounce = false
local house_1 = workspace:WaitForChild("House")
local house_1_pieces = house_1:WaitForChild("Building")
local house_1_health = house_1:WaitForChild("Config"):WaitForChild("Health")
for _, parts in pairs(house_1_pieces:GetChildren()) do
parts.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("Humanoid") ~= nil then
if parts:FindFirstChild("wasTouched").Value ~= true then
if debounce ~= true then
debounce = true
local unRounded = house_1_health.Value - (house_1_health.Value/#house_1_pieces:GetChildren())
house_1_health.Value = math.floor(((unRounded*100)+0.5))/100
parts.wasTouched.Value = true
local start = Color3.new(1,1,1)
local End = Color3.new(1,0,0)
parts.Color = Color3.fromRGB(255, 255, 255)
parts.Anchored = false
parts.Material = Enum.Material.Neon
wait(0.1)
debounce = false
wait(1)
parts.Color = Color3.fromRGB(255, 0,0)
end
end
end
end)
end
Inside the "Health" BillboardGui:
script.Parent.Text = "Health: 100%"
workspace:WaitForChild("House").Config.Health.Changed:Connect(function()
script.Parent.Text = "Health: "..workspace:WaitForChild("House").Config.Health.Value.."%"
end)

2 comments
its in line 13 somehow
That's what I thought, but I cant figure out how