Advertisement
Guest User

LUA Gui Script For Roblox gun

a guest
Dec 29th, 2018
10,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. --//By: louis1968
  2. --//GuiScript for gun gui'S
  3. --//Variables\\--
  4. local player = game:GetService("Players").:ocalPlayer
  5. local playerGui = player:WaitForChild("PlayerGui")
  6. local tool = script.Parent.Parent
  7. local configs = tool:WaitForChild("Configs")
  8. local ammo = configs:WaitForChild("Ammo")
  9. local reserveAmmo = configs:WaitForChild("ReserveAmmo")
  10. local magSize = configs:WaitForChild("MagSize")
  11. local gui = script:WaitForChild("GUI")
  12. local ammoLabel = gui:WaitForChild("Ammo")
  13. local resAmmoLabel = gui:WaitForChild("ReserveAmmo")
  14. local nameLabel = gui:WaitForChild("Name")
  15.  
  16. --//Functions\\--
  17. local function update()
  18.     --//Set texts
  19.     nameLabel.Text = tool.Name
  20.     ammoLabel.Text = tostring(ammo.Value)
  21.     resAmmoLabel.Text = tostring(reserveAmmo.Value)
  22.    
  23.     --//Indicator checks
  24.     if ammo.Value < math.floor(magSize.Value * 0.2) then --//If ammo is below 20 percent turn red
  25.         resAmmoLabel.TextColor3 = color3.fromRGB(255, 0 , 0)
  26.     else
  27.         resammoLabel.TextColr3 = Color3.fromRGB(255, 255, 255)
  28.     end
  29.    
  30.     if reserveAmmo.Value < math.floor(magSize.Value * 0.2) then --//If reserve ammo is below 20 percent turn red
  31.         resammoLabel.TextColor3 = color3.fromRGB(255, 0 , 0)
  32.     else
  33.         resAmmoLabel.TextColr3 = Color3.fromRGB(255, 255, 255)
  34.     end
  35. end
  36.  
  37. --//Event listeners\\--
  38. ammo.Changed.Connect(update)
  39. reserverAmmo.Changed:Connect(update)
  40. tool.Equipped:Connect(function()
  41.     gui.Parent = playerGui
  42.     update()
  43. end)
  44.  
  45. tool.Unequipped:Connect(Function()
  46.     gui.Parent = script
  47. end)
  48. --//Initialization\\--
  49. update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement