I get this error:
Workspace.SellPlatform.SellScript:29: attempt to index a nil value
For this script:
-- When a player touches the parent object, their items will be sold for gold local sellPart = script.Parent -- Gives the player gold for each item they have local function sellItems(playerItems, playerGold) -- Gives players 100 pieces of gold for each item local totalSell = (playerItems.Value * 100) playerGold.Value = playerGold.Value + totalSell playerItems.Value = 0 end local function onTouch(partTouched) -- Looks for a Humanoid local character = partTouched.Parent local humanoid = character:FindFirstChildWhichIsA("Humanoid") -- If a humanoid is found, gets leaderstats and calls sellItems function if humanoid then -- Get the player, so changes can be made to the player's leaderstats local player = game.Players:GetPlayerFromCharacter(humanoid.Parent) local playerStats = player:FindFirstChild("leaderstats") local playerSpaces = playerStats:FindFirstChild("Spaces") local playerItems = playerStats:FindFirstChild("Items") local playerGold = playerStats:FindFirstChild("Gold") local playerStats2 = player:FindFirstChild("Stats") local playerSold = playerStats2:FindFirstChild("Sold") local playerSoldRequired = playerStats2:FindFirstChild("SoldRequired") local playerLevel = playerStats2:FindFirstChild("Level") local playerLevelGui = player.PlayerGui:FindFirstChild("Stats").Level -- Sells Items and then changes the player's spaces and money playerSold.Value = playerSold.Value + playerItems.Value sellItems(playerItems, playerGold) if playerSold.Value >= playerSoldRequired.Value and playerSpaces.Value >= playerItems.Value then playerLevel.Value = playerLevel.Value + 1 playerLevelGui.Visible = true playerSoldRequired.Value = playerLevel.Value * 100 + playerSoldRequired.Value playerSold.Value = 0 end end end sellPart.Touched:Connect(onTouch)