Hello, i'm trying to make a GUI where players can buy Premium. I tried a script i found for a teleport and remaked it for a gui but didn't worked.
Here is the script:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local showPrompt = true
script.Parent.MouseButton1Down:Connect(function()
local player = Players.LocalPlayer
if player.MembershipType == Enum.MembershipType.Premium then
script.Parent.Parent.Parent.Parent.Visible=false
script.Parent.Parent.Parent.Parent.Parent.PremiumError.Frame.Visible=true
wait(3)
script.Parent.Parent.Parent.Parent.Parent.PremiumError.Frame.Visible=false
script.Parent.Parent.Parent.Parent.Visible=true
else
if showPrompt == false then return end
showPrompt = false
delay(5, function()
showPrompt = true
end)
MarketplaceService:PromptPremiumPurchase(player)
warn("Prompted Premium purchase")
end
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
warn("Premium modal closed")
end)
Players.PlayerMembershipChanged:Connect(function(player)
warn("Player membership changed; new membership is " .. tostring(player.MembershipType))
if player.MembershipType == Enum.MembershipType.Premium then
script.Parent.Parent.Parent.Parent.Visible=false
script.Parent.Parent.Parent.Parent.Parent.PremiumUpdate.Frame.Visible=true
wait(3)
script.Parent.Parent.Parent.Parent.Parent.PremiumUpdate.Frame.Visible=false
script.Parent.Parent.Parent.Parent.Visible=true
end
end)
end)
Thanks for the help already!

1 comment
Btw, if you want a screen of the gui etc.. tell me i'll send it!