I am getting this error every time this script is run in ServerScriptService:
ServerScriptService.ExtraTapsHandler:8: attempt to index nil with ‘leaderstats’
Code:
local MPS = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer
function ChangeCurrencyAmount(CurrentTaps)
return math.ceil(CurrentTaps*40)
end
local Amount = ChangeCurrencyAmount(game.Players.LocalPlayer.leaderstats.Taps.Value)
Player.PlayerGui.ShowScores.Frame.BuyTap40.AmountYouGet.Text = Amount
Player.leaderstats.Taps.Value.Changed:Connect(function()
local Amount = ChangeCurrencyAmount(Player.leaderstats.Taps.Value)
Player.PlayerGui.ShowScores.Frame.BuyTap40.AmountYouGet.Text = Amount
end)
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1275015820 then -- replace with your ID here
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value += Amount
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Help is be much appriciated!
Thanks
-GreenTreeGamingYT