local generator = script.Parent.Parent local hum = script.Parent local StatusGUI = generator.StatusGUI local bar = StatusGUI.background.bar local bar2 = StatusGUI.background.bar2 local recharge = script.recharge function status() bar:TweenSize(UDim2.new(hum.Health/hum.MaxHealth,0,1,0, "Out","Quad")) StatusGUI.background.title.Text = generator.Name if hum.Health >= 0.7 * hum.MaxHealth then bar.BackgroundColor3 = Color3.fromRGB(0,255,0) elseif hum.Health < 0.7 * hum.MaxHealth and hum.health > 0.5 * hum.MaxHealth then bar.BackgroundColor3 = Color3.fromRGB(255,255,0) elseif hum.Health < 0.5 * hum.MaxHealth and hum.health > 0.3 * hum.MaxHealth then bar.BackgroundColor3 = Color3.fromRGB(255,170,0) elseif hum.Health < 0.3 * hum.MaxHealth then bar.BackgroundColor3 = Color3.fromRGB(255,0,0) end if hum.Health > 0 then workspace.FF.Transparency = .45 workspace.FF.CanCollide = true elseif hum.Health == 0 then workspace.FF.Transparency = 1 workspace.FF.CanCollide = false end end hum.HealthChanged:Connect(status) while wait(0.12) do bar2:TweenSize(UDim2.new(recharge.Value/hum.MaxHealth,0,0.25,0, "Out","Quad")) if hum.Health == 0 and recharge.Value < hum.MaxHealth then recharge.Value = recharge.Value + 1 elseif recharge.Value == hum.MaxHealth then recharge.Value = 0 hum.Health = hum.MaxHealth end end
Okay revising my answer now based on what you have told me.
So inorder to fix the client not seeing it as an animate objects you might have to get rid of that humanoid and make your own 'fake humanoid'
How I would do this is insert two NumberValue
that represents the MaxHealth and Health into the Generator.
So the MaxHealth
would be like 10 and then whenever someone attacks the generator the health keeps going down from there.
As for the regeneration of the Health
you would just use your while loop
and make the Health increase until it reaches max health.
You would have to connect that health to the status's health. From there you can make it to where whenever the player attacks the Generator, the numbervalue changes, and when that number value changes the billboard gui changes as well.
If you want the player to be able to interact with a Billboard Gui it must be in the startergui. If not you can just leave it inside of the generator.
Make sure the billboardgui is in the StarterGui folder as so: --Only if the player can edit it https://gyazo.com/8af0b7e47975d72f66f9f6a0681ea4b1
1) Inside of the player, you would put a localscript and inside of it make sure that everytime the generator's health changes the player recognizes it.
EX:
local Plr = game.Players.LocalPlayer repeat wait() until Plr.Character local Char = Plr.Character local Hum = Char:WaitForChild('Humanoid') local Generator = --where the generator is located in workspace or wherever local GenHumanoid = Generator.Humanoid local StatusGui = StarterGui.StatusGUI function status () --blah blah end GenHumanoid.HealthChanged:Connect(function() Status() end)
This will connect you locally to your generator's humanoid. The player can change the generator's health from the client by exploiting but it won't be updated to the server. That being said the change in health that player may see from doing so won't be the ACTUAL health.
Closed as Too Broad by User#24403, Leamir, zblox164, and DinozCreates
This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.
Why was this question closed?