local MarketplaceService = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local id = 985264450
local function processReceipt(recieptInfo)
local plr = plrs:GetPlayerByUserId(recieptInfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if plr then
game.Players.LocalPlayer.Gems.Value = game.Players.LocalPlayer.Gems.Value + 100
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
✓ ANSWER ACCEPTED
How do i fix: "Attempt to index nil with 'IntValue'"?
1 answer
✓ Accepted answer
Hello.
Problem
You used LocalPlayer in a ServerScript, which doesn't work because a ServerScript doesn't run on the client. Instead, it runs on a physical server.
Solution
Use the "plr" variable you made instead of LocalPlayer
Fixed Script:
local MarketplaceService = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local id = 985264450
local function processReceipt(recieptInfo)
local plr = plrs:GetPlayerByUserId(recieptInfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if plr then
plr.Gems.Value = plr.Gems.Value + 100
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
Please accept this answer if it helped. There's been a bug for new users that you have to go into incognito mode to accept an answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It is line 14 where the problem is
You can't change values on the client.