Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//By: louis1968
- --//GuiScript for gun gui'S
- --//Variables\\--
- local player = game:GetService("Players").:ocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local tool = script.Parent.Parent
- local configs = tool:WaitForChild("Configs")
- local ammo = configs:WaitForChild("Ammo")
- local reserveAmmo = configs:WaitForChild("ReserveAmmo")
- local magSize = configs:WaitForChild("MagSize")
- local gui = script:WaitForChild("GUI")
- local ammoLabel = gui:WaitForChild("Ammo")
- local resAmmoLabel = gui:WaitForChild("ReserveAmmo")
- local nameLabel = gui:WaitForChild("Name")
- --//Functions\\--
- local function update()
- --//Set texts
- nameLabel.Text = tool.Name
- ammoLabel.Text = tostring(ammo.Value)
- resAmmoLabel.Text = tostring(reserveAmmo.Value)
- --//Indicator checks
- if ammo.Value < math.floor(magSize.Value * 0.2) then --//If ammo is below 20 percent turn red
- resAmmoLabel.TextColor3 = color3.fromRGB(255, 0 , 0)
- else
- resammoLabel.TextColr3 = Color3.fromRGB(255, 255, 255)
- end
- if reserveAmmo.Value < math.floor(magSize.Value * 0.2) then --//If reserve ammo is below 20 percent turn red
- resammoLabel.TextColor3 = color3.fromRGB(255, 0 , 0)
- else
- resAmmoLabel.TextColr3 = Color3.fromRGB(255, 255, 255)
- end
- end
- --//Event listeners\\--
- ammo.Changed.Connect(update)
- reserverAmmo.Changed:Connect(update)
- tool.Equipped:Connect(function()
- gui.Parent = playerGui
- update()
- end)
- tool.Unequipped:Connect(Function()
- gui.Parent = script
- end)
- --//Initialization\\--
- update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement