So I've been trying to make a GUI shop for my game, for the longest time and it isn't working out because I don't know anything about scripting.

I put in the ID but it just says the item is unavailable or it can't recharge whenever I try going into the game to test it out.

The script in ServerScriptServices:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

--DONT CHANGE ANYTHING ABOVE HERE--

local gamePassID =  12124664 --GAMEPASS ID HERE, REPLACE "NIL" WITH ID

--DONT CHANGE ANYTHING BELOW HERE--

function Spawned(player)
	
	local HasGamepass = false
	
	local success, message = pcall(function()
		HasGamepass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
	end)
	
	if not success then
		warn("Checking In Player Has Gamepass" .. tostring(message))
		return
	end
	
	if HasGamepass == true then
		game.ServerStorage.GamepassItems.GravityCoil:Clone().Parent = player.Backpack --THE ITEM IN QUESTION
	end 
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		Spawned(player)
	end)
end)

Players.PlayerSpawned:Connect(Spawned)

The speed coil button LocalScript:

id = 12124664
player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(player,id)
end)

I've tried a lot of tutorials but they aren't helping.

Also the same goes for my developer products too.. Those won't work either.

The script:

id = 1128753076
player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptPurchase(player,id)
end)

4 comments

0

Ah my bad, on the title I meant sale*

0

maybe try a loop somewhere? Your script is too long and I'm kinda impatient so I would recommend you to watch youtube tutorials

0

Why do the IDs differ?

0

@Ziffixture Because they are different gears, one is a speed coild other is gravity coil Imao,