Why is my script not working?

image
( Not errors associated with the script :confused: )

Can you include the rest of the dev product code? Developer Products require more code than what you provided, so I figure the issue is in there.

game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
	for i,v in pairs(game.Players:GetChildren()) do
		if v.userId == id then
			return v
		end
	end
	return nil
end
 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	local productId = receiptInfo.ProductId
	local playerId = receiptInfo.PlayerId
	local player = getPlayerFromId(playerId)
	local productName 
	-------------------------------------------------------------------
	
	if productId == 0 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 5000
			end
		-------------------------------------------------------------------
	
		elseif productId == 0 then
		local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
		local char = player.Character
		char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 15
		wait()
		char.Humanoid.Health = char.Humanoid.MaxHealth
		-------------------------------------------------------------------
	
		-- Down below is an example of a WalkSpeed boost
	
		-------------------------------------------------------------------
		elseif productId == 0 then
		local char = player.Character
		if char then
			local human = char:FindFirstChild("Humanoid")
			if human then
				human.WalkSpeed = human.WalkSpeed + 15
			end
		end
		-------------------------------------------------------------------

    	elseif productId == 0 then
		game.ServerStorage.Sword:Clone().Parent=player.Backpack
		
		elseif productId == 0 then
		game.ServerStorage.Sword2:Clone().Parent=player.Backpack  
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

I dont really know whats wrong with the script to be honest…

You must replace the ID variables below for this to work.
The must not have “” (that’s a string)
It has to be 00000000 (a number value)

If this does not work please be specific of what doesn’t work.
Use F9 to show us any errors!

local MarketplaceService = game:GetService("MarketplaceService")

local GiveCashID = 0
local IncreaseHealthID = 0
local IncreaseWalkSpeedID = 0
local SwordOneID = 0
local SwordTwoID = 0


function getPlayerFromId(id)
	for i,v in pairs(game.Players:GetChildren()) do
		if v.userId == id then
			return v
		end
	end
	return nil
end
 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	local productId = receiptInfo.ProductId
	local playerId = receiptInfo.PlayerId
	local player = getPlayerFromId(playerId)
	
	if productId == GiveCashID then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        
		if cashmoney then
			cashmoney.Value = cashmoney.Value + 5000
		end
	elseif productId == IncreaseHealthID then
		local char = player.Character
		char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 15
	elseif productId == IncreaseWalkSpeedID then
        local char = player.Character
        
		if char then
			local human = char:FindFirstChild("Humanoid")
			if human then
				human.WalkSpeed = human.WalkSpeed + 15
			end
		end
    elseif productId == SwordOneID then
		game.ServerStorage.Sword:Clone().Parent = player.StarterGear
		
	elseif productId == SwordTwoID then
		game.ServerStorage.Sword2:Clone().Parent = player.StarterGear  
    end
    
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end


also i edited it so i could use more devproducts

local MarketplaceService = game:GetService("MarketplaceService")

local GiveCashID = 0
local IncreaseHealthID = 0
local IncreaseWalkSpeedID = 0
local SwordOneID = 0
local SwordTwoID = 0


function getPlayerFromId(id)
	for i,v in pairs(game.Players:GetChildren()) do
		if v.userId == id then
			return v
		end
	end
	return nil
end
 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	local productId = receiptInfo.ProductId
	local playerId = receiptInfo.PlayerId
	local player = getPlayerFromId(playerId)
	
	if productId == 1081526257 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        
		if cashmoney then
			cashmoney.Value = cashmoney.Value + 1000
			
			elseif productId == 1081532144 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        
		if cashmoney then
			cashmoney.Value = cashmoney.Value + 10000
		end
	elseif productId == IncreaseHealthID then
		local char = player.Character
		char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 15
	elseif productId == IncreaseWalkSpeedID then
        local char = player.Character
        
		if char then
			local human = char:FindFirstChild("Humanoid")
			if human then
				human.WalkSpeed = human.WalkSpeed + 15
			end
		end
    elseif productId == SwordOneID then
		game.ServerStorage.Sword:Clone().Parent = player.StarterGear
		
	elseif productId == SwordTwoID then
		game.ServerStorage.Sword2:Clone().Parent = player.StarterGear  
    end
    
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

:frowning:

You don’t understand how LUA works, I recommend you start out more basic.

Here is a tutorial to start your adventure in RLUA
https://education.roblox.com/en-us/resources/intro-to-coding

I found fixed DevProduct Script:

-- If you do not know how to use this or the GUI, check out my YouTube video tutorial on this. 
-- Replace the 0's with your ID's 
-- Delete what you dont use, besides the first part of the function


game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
	for i,v in pairs(game.Players:GetChildren()) do
		if v.userId == id then
			return v
		end
	end
	return nil
end
 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	local productId = receiptInfo.ProductId
	local playerId = receiptInfo.PlayerId
	local player = getPlayerFromId(playerId)
	local productName 
	
	-- Down below is an example of a Cash boost
	
	-------------------------------------------------------------------
	
	if productId == 1081526257 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 1000
			end
			
			
			
		elseif productId == 1081532144 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 10000
			end	
			
		elseif productId == 1081969350 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 1000000
			end
			
			elseif productId == 1081969174 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 1000000000
			end
			
		-------------------------------------------------------------------
	
		-- Down below is an example of a Health boost
		
		-------------------------------------------------------------------
	
		elseif productId == 30912742 then
		local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
		local char = player.Character
		char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
		wait()
		char.Humanoid.Health = char.Humanoid.MaxHealth
		-------------------------------------------------------------------
	
		-- Down below is an example of a WalkSpeed boost
	
		-------------------------------------------------------------------
		elseif productId == 1081973784 then
		local char = player.Character
		if char then
			local human = char:FindFirstChild("Humanoid")
			if human then
				human.WalkSpeed = human.WalkSpeed + 100
			end
		end
		-------------------------------------------------------------------
		
		-- Down below is an example of a gear giver
		
		-------------------------------------------------------------------
		
    	elseif productId == 30912801 then
		game.ServerStorage.Sword:Clone().Parent=player.Backpack
		
		elseif productId == 0 then
		game.ServerStorage.Sword2:Clone().Parent=player.Backpack  -- Example if you want to make another gear giver, delete the 2 lines if you dont need it
	
		-------------------------------------------------------------------
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

Replace my ID’s with yours. Enjoy

That’s not what a solution needs to be. There’s nothing explaining what the problem fix was nor is that snippet of code even valid as you’re missing an end.

If i would know what was the problem i wouldn’t ask people on DevForum how to fix it. I just found fixed one. :slight_smile:

You still didn’t even fix it. You posted a snippet that doesn’t actually work nor did you explain what you did to fix it.

Okay. I did an edit. Is it good now? :slight_smile:

If it’s working, awesome. But, this isn’t the best way to learn. You’re essentially throwing yourself in the deep end and asking us to keep you afloat. Developer Products are a more advanced concept, I suggest getting a grasp on the basics first. It will help you in the long run.

Im currently watching some basics tutorials. I just wanted to finish the game because its almost finished. I know im not the best, im not even good. Wish me luck, have a nice day :slight_smile:

1 Like

No, it isn’t actually. You posted something entirely different still not explaining what fixed your script.