Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

SCRIPT WONT WORK, PLEASE HELP! Script where if players have certain item they get free coins?

SCRIPT WONT WORK, PLEASE HELP! I need a script where if players have certain gamepass they get free coins! I need this so creators get free stuff, please help!

1 answer

Ok, your not supposed to ask for stuff without showing script but ok.

-- 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 == 50738839 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 5000
			       end
	elseif productId ==50738869  then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 10000
			end
	elseif productId == 50738905 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 20000
			end
	elseif productId == 50738942 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 30000
			end	
    elseif productId == 50738971 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 40000
			end
	elseif productId == 50739005 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 99999999999
			end
			
			
			
			
		-------------------------------------------------------------------
	
		-- Down below is an example of a Health boost
		
		-------------------------------------------------------------------
		elseif productId == 52085900 then
		local char = player.Character
		if char then
			local human = char:FindFirstChild("Humanoid")
			if human then
				human.WalkSpeed = human.WalkSpeed + 15
			end
		end
		-------------------------------------------------------------------
	
		-- Down below is an example of a WalkSpeed boost
	
		-------------------------------------------------------------------
		elseif productId == 52086187 then
		local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
		local char = player.Character
		char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 30
		wait()
		char.Humanoid.Health = char.Humanoid.MaxHealth
		-------------------------------------------------------------------
		
		-- Down below is an example of a gear giver
		
		-------------------------------------------------------------------
		
    	elseif productId == 52086215 then
		game.ServerStorage.Rainbow:Clone().Parent=player.Backpack
		
		-------------------------------------------------------------------
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

This discussion is preserved as it was. New answers, comments, and votes are closed.