Clone not working

Hey there fellow devs,
I got this script here that is supposed to clone a frame and make the text the players name if they own a gamepass but it is not working and im not sure why
Final Goal: To clone a frame if a player owns a gamepass and change the text.

game.Players.PlayerAdded:Connect(function(plr)
local id = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template
	
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
		if purchased and id == id then
			local clonetemplate = template:Clone()
			clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
			clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
			end
		end)
	end)

Are you sure that the :Clone() is even firing, just put a few prints to find out whats running and whats not

1 Like

alright, thanks ill try that out

the prints stop working after this line

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)

Have you simulated buying a game pass in game (it won’t charge your account) that would fire the event

1 Like
local id = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template
	
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
		if purchased and id == id then
			local clonetemplate = template:Clone()
			clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
			clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
		end
	end)

try this the first player added isnt needed

No i havent, 12345678912345678

Didnt work sorry 30303030303030

is you thing a gamepass or devproduct?

It is a gamepass. 303030303030

Try changing the id parameter in the function to gamePassId or something, that might be the problem.

local passid = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template
	
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
		if purchased == true and id == passid then
			local clonetemplate = template:Clone()
			clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
			clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
		end
end)

try this

I forgot exactly how but

local MarketplaceService = game:GetService("MarketplaceService")

local gamepass_id = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template

game.Players.PlayerAdded:Connect(function(player)
    wait(5)
    MarketplaceService:PromptGamePassPurchase(player, gamepass_id)
end)
	
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
	if purchased and gamepass_id == id then
		local clonetemplate = template:Clone()
		clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
		clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
	end
end)

This will prompt the user the gamepass on join (you can remove this after testing)

Accept it (it wont charge you anything in studio) and see if the prints fire

1 Like

alright ty 3030303030030303034444

didnt work 30303030303030303030

they prompt showed up and said i owned it

Try this script:

local MarketplaceService = game:GetService("MarketplaceService")

local gamepass_id = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template

game.Players.PlayerAdded:Connect(function(player)  
   if MarketplaceService:UserOwnsGamePassAsync(player, gamepass_id) then
        local clonetemplate = template:Clone()
		clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
		clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
   end 
end)
	
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
	if purchased and gamepass_id == id then
		local clonetemplate = template:Clone()
		clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
		clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
	end
end)
1 Like

It didnt work but it has to be a server script right? and i was at school sorry

Uhh… did it gave any errors in output? Because i think it should’ve worked…

1 Like
game.Players.PlayerAdded:Connect(function(plr)
local id = 19037029
local template = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame.Template
local clonetemplate = template
	
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,id,purchased)
		if purchased and id == id then
			clonetemplate:Clone()
			clonetemplate.Parent = game.Workspace.Thanks.SurfaceGui.Frame.ScrollingFrame
			clonetemplate.Text1.Text = "πŸ‘‘πŸ’–"..plr.Name.."πŸ‘‘πŸ’–" 
			end
		end)
	end)
1 Like