Advertisement
HowToRoblox

JuggernautGuiHandler

Dec 12th, 2022
1,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. local client = game.Players.LocalPlayer
  2.  
  3. local dataFailedWarning = script.Parent:WaitForChild("DataFailedWarning")
  4. dataFailedWarning.Enabled = false
  5.  
  6. client.ChildAdded:Connect(function(child)
  7.     if child.Name == "FAILED TO LOAD DATA" then
  8.         dataFailedWarning.Enabled = true
  9.     end
  10. end)
  11.  
  12.  
  13. local rs = game.ReplicatedStorage:WaitForChild("JuggernautReplicatedStorage")
  14. local config = require(rs:WaitForChild("Settings"))
  15. local status = rs:WaitForChild("STATUS")
  16.  
  17. local mainGui = script.Parent:WaitForChild("JuggernautGui")
  18. local healthBar = mainGui:WaitForChild("JuggernautHealthBar")
  19. local statusLabel = mainGui:WaitForChild("StatusLabel")
  20. healthBar.Visible, statusLabel.Visible = false, true
  21.  
  22.  
  23. function updateStatusLabel()
  24.     statusLabel.Text = status.Value
  25. end
  26. updateStatusLabel()
  27. status:GetPropertyChangedSignal("Value"):Connect(updateStatusLabel)
  28.  
  29.  
  30. function updateHealthBar(health)
  31.     local maxHealth = config.JuggernautHumanoidProperties.MaxHealth
  32.     local scale = health / maxHealth
  33.    
  34.     healthBar.Health.Text = health .. "/" .. maxHealth
  35.     healthBar.Bar:TweenSize(UDim2.new(scale, 0, 1, 0), "InOut", "Linear", 0.2)
  36.    
  37.     healthBar.Visible = true
  38. end
  39.  
  40. rs.ChildAdded:Connect(function(child)
  41.     if child.Name == "JUGGERNAUT HEALTH" then
  42.        
  43.         updateHealthBar(child.Value)
  44.         child:GetPropertyChangedSignal("Value"):Connect(function()
  45.             updateHealthBar(child.Value)
  46.         end)
  47.        
  48.         child.AncestryChanged:Connect(function()
  49.             if child.Parent == nil then
  50.                 healthBar.Visible = false
  51.             end
  52.         end)
  53.     end
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement