Whenever I unequip and re-equip the gun, the GUI shows up, but the text appears to be wrong.
Updating Ammo:
--//Variables
local plr = game.Players.LocalPlayer
local plrgui = plr:WaitForChild("PlayerGui")
local AmmoGui = plrgui:WaitForChild("AmmoGui")
local Frame = AmmoGui:WaitForChild("Frame")
local tool = script.Parent
local config = tool:WaitForChild("Config")
local ammo = config:WaitForChild("Ammo")
local clips = config:WaitForChild("Clips")
local display = Frame:WaitForChild("Display")
--//Function(s)
local function Update()
display.Text = ammo.Value .. "/" .. clips.Value
wait()
end
--//Events
tool.Activated:connect(Update)
ammo.Changed:connect(Update)
clips.Changed:connect(Update)
tool.Equipped:connect(function()
display.Visible = true
Update()
end)
Cloning Ammo GUI:
local plr = game.Players.LocalPlayer
local playerGui = plr:WaitForChild("PlayerGui")
local controlGuiClass = script.Parent.Parent.AmmoGui
local tool=script.Parent.Parent
tool.Equipped:connect(function()
local CGClone = controlGuiClass:Clone()
CGClone.Parent = playerGui
CGClone.Frame.Display.Visible = true
end)
--this is in ControlsGui local script
tool.Unequipped:Connect(function()
if playerGui:FindFirstChild("AmmoGui") then -- B/c it'll check the original variable, which you'll have to have the script
playerGui.AmmoGui:Destroy()
end
end)
Hopefully there's a way to fix this..
-LukeGabrieI

1 comment
The gun looks really cool.