Hey, Gang.
I’ve got this script that changes the transparency of parts in a viewmodel, so that when the player inspects the viewmodel the amount of bullets in a magazine updates with the current mag count.
However what i’m using is kinda ineffective. I want to have it so that every part with a number above the current magazine count is turned transparent. How would i go about it?
function checkForBullets(viewmodel)
coroutine.wrap(function()
if viewmodel and Reloading ~= true then
local mag = viewmodel:FindFirstChild("Bullets")
for _, v in pairs(mag:GetDescendants()) do
if v:IsA("BasePart") then
if Mag < MaxAmmo then
if v.Name == "ammo_0"..Mag + 1 or v.Name == "ammo_".. Mag+ 1 then
v.Transparency = 1
end
end
if Mag <= 0 then
v.Transparency = 1
end
end
end
end
end)()
end
function resetBullets(viewmodel)
coroutine.wrap(function()
if viewmodel then
local mag = viewmodel:FindFirstChild("Bullets")
for _, v in pairs(mag:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
end
end
end
end)()
end