I made a script for my custom health bar to make my player invincible for 3 seconds... didn't work, no output errors. Anyone know whats wrong? script:
local Plr = game.Players.LocalPlayer local Char = Plr.Character script.Parent.Changed:connect(function(val) if script.Parent.Value >0 then local Health = script.Parent.Value for index, child in pairs(Char:GetChildren()) do if child:IsA("Part") then while wait(3) do if val ~= Health then script.Parent.Value = Health child.Transparency = 0 wait(0.35) child.Transparency = 1 elseif val == Health then child.Transparency = 0 wait(0.35) child.Transparency = 1 wait() -- anti freeze end end chilf.Transparency = 1 end end end end)
This will work I fixed it
local Plr = game.Players.LocalPlayer local Char = Plr.Character script.Parent.Changed:connect(function(val) if script.Parent.Value >0 then local Health = script.Parent for index, child in pairs(Char:GetChildren()) do if child:IsA("Part") then while wait(3) do if val ~= Health.Value then script.Parent.Value = Health.Value child.Transparency = 0 wait(0.35) child.Transparency = 1 elseif val == Health.Value then child.Transparency = 0 wait(0.35) child.Transparency = 1 wait() -- anti freeze end end child.Transparency = 1 end end end end)
If it's a local script just add a wait(2) at the very start of the script and it should work.