So basically I'm trying to make a character gamepass. The idea is when someone buys the gamepass their current character will turn into the StarterCharacter I made. The problem is, I can buy the gamepass but nothing is changing.

The Script is in ServerScriptService and StarterCharacter is in ServerStorage.

local gamepass_id = (16052828)
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")
local GamepassStarterCharacter = ServerStorage.StarterCharacter

local GamepassFunction = function(Player)
	if not Player:IsA("Player") then
		return
	end
	Player.CharacterAdded:Connect(function(Character)
		local function LoadCharacter(Path)
			for i,v in pairs(Character:GetChildren()) do
				v:Destroy()
			end
			for i,v in pairs(Path:GetChildren()) do
				v:Clone().Parent = Character
			end
			if not Character:FindFirstChildOfClass("Humanoid") then
				Instance.new("Humanoid",Character)
			end
		end
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,gamepass_id) then
			LoadCharacter(GamepassStarterCharacter)
			print("Y")
		else
			print("N")
		end
	end)
end

for i,v in pairs(Players:GetPlayers()) do
	GamepassFunction(v)
end
Players.PlayerAdded:Connect(GamepassFunction)

And incase there is an error here, this is the LocalScript inside a button text inside a gamepass shop gui I'm currently using.

local mps = game:GetService("MarketplaceService")
local gamepass_id = 16052828

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	mps:PromptGamePassPurchase(player, gamepass_id)
end)

mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)
	if id == gamepass_id and purchased then
		print("Purchased")
	end
end) 

Also, I opened the gamepass sales. And when I try to buy the gamepass it prints "Purchased" but doesn't print "Y" or "N"

Thanks!

1 comment

0

Would appreciate your help.