Ok so i have this gun that displays its name and its ammo ammount. The problem is when i have different guns with the same script inside it gets weird and tries to put both names in it and so it just flickers. I found the problem, its in the code below. It is ebcause they wait(0) aand try to find the “GunHud” so how would i fix it so only the equiped gun will show its name and amount?
while wait(0) do
if game.Players.LocalPlayer.PlayerGui:FindFirstChild("GunHUD") then
game.Players.LocalPlayer.PlayerGui:FindFirstChild("GunHUD").GunName.Text = script.Parent.Name
game.Players.LocalPlayer.PlayerGui:FindFirstChild("GunHUD").CurrentAmmo.Text = Settings.CurrentAmmo.Value.."/"..Settings.MagSize.Value
print(Settings.CurrentAmmo.Parent.Parent.Name)
end
if state.autoShooting and state.equipped and Coroutine.Value == false and not isReloading then
handleShot()
end
end