Below works and all but it only works one time for some reason. Basically what it does it checks if something that touches it is a zombie and if it is it loses health from the zombie by -1 from a value that is displayed on a GUI. For some reason it subtracts 20 from it but when the zombie touches it again nothing happens.
function onTouch(part) local h = part.Parent:FindFirstChild("Zombie torso") wait(3) if h~=nil then for i, v in ipairs(game.Players:GetChildren()) do local n = v.PlayerGui.Notice.Box.Health1.Health.Value n = (n -20) v.PlayerGui.Notice.Box.Health1.Text = n game.StarterGui.Notice.Box.Health1.Text = n end end end script.Parent.Touched:connect(onTouch)
Because of this line local n = v.PlayerGui.Notice.Box.Health1.Health.Value
your script only subtracts 20 once.
In the script, you never subtract 20 from the value.
local healthVal = v.PlayerGui.Notice.Box.Health1.Health healthVal.Value = healthVal.Value - 20 --Subtract from value and set new value -- Change Text to healthvalue v.PlayerGui.Notice.Box.Health1.Text = healthVal.Value game.StarterGui.Notice.Box.Health1.Text = healthVal.Value