Weapon GUI Icon Not changing color when first Equipped / Unequipped

So I was working on making an Icon Changing colors when Equipped / Unequipped But the first time it’s equipped it doesn’t change the color and the other times I equip it does change, The script prints out no errors and there are no bugs, How can I fix this?

local UIS = game:GetService("UserInputService")
wait(0.1)
local h = script.Parent.Parent.Parent.Character.Humanoid
local ak47 
local a 

a = false


UIS.InputBegan:Connect(function(key)	
	local k = key.KeyCode
	if k == Enum.KeyCode.One then
		if a == false then			
			
			local tween = game:GetService("TweenService")
			local dest = {}
			dest.ImageColor3 = Color3.fromRGB(255,255,255)
			local tweeninfo = TweenInfo.new(0.2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
			local fin = tween:Create(script.Parent.ImageLabel,tweeninfo,dest)

			local Player = game.Players.LocalPlayer
			local Character = Player.Character or Player.CharacterAdded:Wait()
			print("first")
			Character.ChildAdded:Connect(function(NewChild)
				if NewChild:IsA("Tool") then	
					print("Equipped")
					fin:Play()
					wait()
					a = true
				end
			end)
		end
	end
end)


UIS.InputBegan:Connect(function(key2)
	local k1 = key2.KeyCode
	if k1 == Enum.KeyCode.One then
		if a == true then
			
			local tween2 = game:GetService("TweenService")
			local dest2 = {}
			dest2.ImageColor3 = Color3.fromRGB(0,0,0)
			local tweeninfo2 = TweenInfo.new(0.2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
			local fin2 = tween2:Create(script.Parent.ImageLabel,tweeninfo2,dest2)

			local Player = game.Players.LocalPlayer
			local Character = Player.Character or Player.CharacterAdded:Wait()
			
			Character.ChildRemoved:Connect(function(RemovedChild)
				if RemovedChild:IsA("Tool") then
					print("tool removed")
					fin2:Play()
					a = false
				end
			end)
		end
	end
end)

Any help and feedback appreciated! :happy1: