It's supposed to create a SurfaceGui with a textbutton, that, when clicked, prompts me with a DevProduct. Output doesn't give any errors. Also, this is a localscript in StarterGui.
Code:
game.Players.PlayerAdded:connect(function(p) local pi = 43873080 local SG = Instance.new("SurfaceGui") SG.Parent = game.Workspace.don8 local TB = Instance.new("TextButton") TB.Parent = SG TB.Size = UDim2.new(1,0,1,0) TB.Text = "Click Me!" TB.MouseButton1Down:connect(function() Game:GetService("MarketplaceService"):PromptProductPurchase(p, pi) end) end)
Try this, place the script inside the StarterGui.
local p = game.Players.LocalPlayer local pi = 43873080 local SG = Instance.new("SurfaceGui") SG.Parent = p:WaitForChild("PlayerGui") SG.Adornee = game.Workspace.don8 local TB = Instance.new("TextButton") TB.Parent = SG TB.Size = UDim2.new(1,0,1,0) TB.Text = "Click Me!" TB.MouseButton1Down:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(p, pi) end)
Explaination:
PlayerAdded does not fire for the player entering, because the player is created before the scripts. (Might be wrong on this one, but I surely know that PlayerAdded does not fire for the player entering atleast)
The solution is simple, first create a variable named "p" and point it to the localplayer, then parent SG
to the PlayerGui
and set it's adornee to game.Workspace.don8
. Oh and one last thing, don't use Game
, it's deprecated, instead use game
, hope it helps.