Hi, any help would be appreciated!
I want to check if the player already owns the shirts & if they do, make a gui appear but if they don’t then give them a shirt.
It errors & says: attempt to index nil with ‘Name’ & the word clothes has an error: W001: Unknown Global ‘clothes’
I looked for solutions on the Developer Hub & have experimented by changing the script for hours but it’s still not working.
local cost = 10 -- Cost of the crate
local crateModule = require(game.ServerScriptService:WaitForChild("CrateModule2")) -- Other Crate Script
script.Parent.ClickDetector.MouseClick:Connect(function(player) -- If crate is bought then
if player.leaderstats.Gold.Value >= 10 then -- check they have enough money
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - cost -- and spend it.
local counter = 1
repeat
local clothes = crateModule.chooseRandomClothes() -- Run other script (it will pick a random shirt)
print(clothes.Value.Value.." "..clothes.Colour.Value.." Shirt has been selected!")
wait(0.5) -- Wait 0.5 seconds so studio doesn't crash.
counter += 1 -- add 1 on to the counter
until player.ClothesInventory:FindFirstChild(clothes.Name) == nil or counter >= 18 -- If you already own the shirt then check if you own the other 18 shirts
if player.ClothesInventory:FindFirstChild(clothes.Name) == nil then -- Here is the error, it says: attempt to index nil with 'Name' & the word clothes has an error: W001: Unknown Global 'clothes'
-- if the player doesn't already own the shirt then give them the shirt
elseif counter >= 18 then -- if they own all the shirts then
-- make a gui appear & give their money back
end
end
end)
I’m sorry if this is confusing, if you have any questions please let me know.
Thank you for any help you can offer