Help me fix this script please!

Hello! So here’s the issue,

Someone else made this script (who is awesome!)

So i have an inventory system set up so it checks all the values of the items.

for each gun it has this, GunName > Rarity > Value = LEGENDARY

But whenever this system saves it, it sets it to the RARE color on the inventory GUI. even though it still says LEGENDARY on the Rarity value.
Ill post the Save script and the inventory script.

– Save Script

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ServerStorage = game:GetService("ServerStorage")

Players.PlayerAdded:Connect(function(PlayerAdded)
for a,b in pairs(ServerStorage.Stats:GetChildren()) do
	b:Clone().Parent = PlayerAdded
end

local GetAsync

local Successful, Unsuccessful = pcall(function()
	GetAsync = DataStoreService:GetDataStore("Bullet Rage"):GetAsync(PlayerAdded.UserId)
end)

if Successful and GetAsync then
	for a,b in pairs(GetAsync) do
		for c,d in pairs(PlayerAdded:GetDescendants()) do			
			if d:IsA("ValueBase") and d:IsDescendantOf(PlayerAdded.Items) or     d:IsDescendantOf(PlayerAdded.Hats) or d:IsDescendantOf(PlayerAdded.Other) or d:IsDescendantOf(PlayerAdded.leaderstats) then
				if tostring(a) == tostring(d) then
					d.Value = b
				end
			end
		end
	end
end
end)


Players.PlayerRemoving:Connect(function(PlayerRemoving)
if not RunService:IsStudio() then
	local SetAsync = {}
	
	for a,b in pairs(PlayerRemoving:GetDescendants()) do
		if b:IsA("ValueBase") and b:IsDescendantOf(PlayerRemoving.Items) or b:IsDescendantOf(PlayerRemoving.Hats) or b:IsDescendantOf(PlayerRemoving.Other) or b:IsDescendantOf(PlayerRemoving.leaderstats) then
			SetAsync[b.Name] = b.Value
		end
	end
	
	local Successful, Unsuccessful = pcall(function()
		DataStoreService:GetDataStore("Bullet Rage"):SetAsync(PlayerRemoving.UserId, SetAsync)
	end)		
end
end)

game:BindToClose(function()
if not RunService:IsStudio() then
	for a,b in pairs(Players:GetPlayers()) do
		local SetAsync = {}
		
		for c,d in pairs(b:GetDescendants()) do
			if d:IsA("ValueBase") and d:IsDescendantOf(b.Items) or d:IsDescendantOf(b.Hats) or d:IsDescendantOf(b.Other) or d:IsDescendantOf(b.leaderstats) then
				SetAsync[d.Name] = d.Value
			end
		end
		
		local Successful, Unsuccessful = pcall(function()
			DataStoreService:GetDataStore("Bullet Rage"):SetAsync(b.UserId, SetAsync)
		end)
	end
end
end)

– Chage color on rarity script,

local GUN = script.Parent.Parent.VALUES.GunName.Value
wait(math.random(0,1))

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "UNCOMMON" then
script.Parent.BackgroundColor3 = Color3.new(90/255,190/255,255/255)
script:Destroy()

end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "RARE" then
script.Parent.BackgroundColor3 = Color3.new(0/255,255/255,0/255)
script:Destroy()

end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "LEGENDARY" then
script.Parent.BackgroundColor3 = Color3.new(255/255,0/255,0/255)
script:Destroy()
end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "EXOTIC" then
script.Parent.BackgroundColor3 = Color3.new(255/255,255/255,0/255)
script:Destroy()
end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "UNREAL" then
script.Parent.BackgroundColor3 = Color3.new(255/255,125/255,0/255)
script:Destroy()
end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "PRISIM" then
script.Parent.BackgroundColor3 = Color3.new(0/255,255/255,255/255)
script:Destroy()
end

if game.Players.LocalPlayer.Items[GUN].Rarity.Value == "IMAGINARY" then
script.Parent.BackgroundColor3 = Color3.new(150/255,255/255,0/255)
script:Destroy()
end

I hope you understand!
Thanks!