Hello, I’m trying to create a cosmetics script receiver that changes the color of the player’s cosmetic. However, the script is trying to find an instance called “purchasedvaluename” instead of finding an instance that matches its string value. Is there any way to fix this?
(SCRIPT BELOW:)
function purchaseItem(player, purchasedvaluename, cost, rgb1, rgb2, rgb3)
local coins = player.leaderstats.Coins
local cosmetic = player.Character.HumanoidRootPart.Cosmetic
local purchased = player.CosmeticsValues.purchasedvaluename.Value
if purchased == true then
cosmetic.Color = Color3.fromRGB(rgb1, rgb2, rgb3)
elseif coins.Value >= cost then --FIX PURCHASE NOT WORKING AS INTENDED
coins.Value = coins.Value - 5
cosmetic.Color = Color3.fromRGB(rgb1, rgb2, rgb3)
purchased = true
print(purchased)
else --If there is an error, then print error, print the player's coins, and print their purchased variable
print("cosmetic error!")
print(tostring(coins.Value))
print(purchased)
end
end
cosmeticevents.GreyBadgePurchase.OnServerEvent:Connect(function(player)
purchaseItem(player, "GreyPurchased", false, 5, 70, 70, 70)
end)
cosmeticevents.RedBadgePurchase.OnServerEvent:Connect(function(player)
purchaseItem(player, "RedPurchased", false, 5, 185, 0, 0)
end)
cosmeticevents.BlueBadgePurchase.OnServerEvent:Connect(function(player)
purchaseItem(player, "BluePurchased", false, 5, 0, 85, 170)
end)