Help With Dev Product

Can somebody tell me what is wrong with my script? I want it where if the player buys the dev product it would change the text of the player’s gui. Thi script is in a server script

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
productFunctions[1112608554] = function(receipt, player)
	if player.Character and player.Character:FindFirstChild("Humanoid") then
		local points = game.Players.LocalPlayer.LevelsInfo.Level
		player.PlayerGui.GUI.MainFrame.Breathing.Value.Text = 0
		player.PlayerGui.GUI.MainFrame.Health.Value.Text = 0
		player.PlayerGui.GUI.MainFrame.Speed.Value.Text = 0
		player.PlayerGui.GUI.MainFrame.Total.Value.Text = points.Value
		player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
		return true
	end
end


local function processReceipt(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	local handler = productFunctions[receiptInfo.ProductId]
	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt

Your probably better off using a Remote Event to tell the client to make these changes as they are just visual

productFunctions[1112608554] = function(receipt, player)
	if player.Character and player.Character:FindFirstChild("Humanoid") then
		RemoteEvent:FireClient(player.UserId, points.Value) -- Pass the points.Value so Total.Value can be edited
        player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
		return true
	end
end

-- Local Script preferably should be a child of GUI.MainFrame

local RemoteEvent = Where ever your remote event is located should be Replicated Storage

local function FunctionName(Points)
    player.PlayerGui.GUI.MainFrame.Breathing.Value.Text = 0
    player.PlayerGui.GUI.MainFrame.Health.Value.Text = 0
	player.PlayerGui.GUI.MainFrame.Speed.Value.Text = 0
	player.PlayerGui.GUI.MainFrame.Total.Value.Text = Points
end

RemoteEvent.OnClientEvent:Connect(FunctionName)

Also you can’t call “LocalPlayer” from a script it has to be a local script inside of
StarterGui
StarterPack
StarterPlayer → StarterPlayerScripts
StarterPlayer → StarterCharacterScripts

Oh wow, so the problem was that I used LocalPlayer, thanks for pointing that out.

Hm, thats weird I’m getting a warning and then the dev product doesn’t work

local function processReceipt(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	local handler = productFunctions[receiptInfo.ProductId]
	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase") -- The warning
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt

Can i see the warning? 30 letters

Thats the warning, it will warn me and print those

weird
not to experienced with Dev products but im pretty experienced with pcalls

local success, result = pcall(handler, receiptInfo, player)

shouldn’t result be the Error that happened if it didn’t work or does it change when using Dev products?

So the firsttime of buying the dev product, it works, but after that i get that. Honeslty i took this script from the roblox developer page

Hmm i dont see your script on the Developer page for Developer Products try reading up on Dev products and see if you find anything ill do the same and get back you if i find anything

i deleted the datastore part of it because it wasn’t needed

Hmm thats weird try adding print statements after each if statement to see whats not working