Hello, so I have this script that I want to give the player + 50 cash, however it gives me an error
ServerScriptService.ProductShopServer:12: attempt to index nil with 'FindFirstChild' - Server - ProductShopServer:12
local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local Fifty = 1681205544
local function GiveFifty(player)
player:FindFirstChild("leaderstats").Cash.Value = player:FindFirstChild("leaderstats").Cash.Value + 50
end
marketplaceService.PromptProductPurchaseFinished:Connect(function(player, Fifty, wasPurchased)
if wasPurchased then
GiveFifty()
end
end)
local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local Fifty = 1681205544
local function GiveFifty(player)
player:FindFirstChild("leaderstats").Cash.Value = player:FindFirstChild("leaderstats").Cash.Value + 50
end
marketplaceService.PromptProductPurchaseFinished:Connect(function(player, Fifty, wasPurchased)
if wasPurchased then
GiveFifty(player)
end
end)
local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local Fifty = 1681205544
local function GiveFifty(player)
player:FindFirstChild("leaderstats").Cash.Value = player:FindFirstChild("leaderstats").Cash.Value + 50
end
marketplaceService.PromptProductPurchaseFinished:Connect(function(playerID, Fifty, wasPurchased)
local player = players:GetPlayerByUserId(playerID)
if wasPurchased then
GiveFifty(player)
end
end)