I’m trying to do a Premium Halo Gamepass for one of my games.
There will be some Free Halos on the menu and then some Paid.
I want help modifying the Equip Halo script for the Equip GUI Button on the Paid Halos.
So here is my idea:
If the Player already has the gamepass, the button will function normally:
local equipped = script.Parent.Parent.Equipped
local unequipped = script.Parent.Parent.Unequipped
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Halo5Remotes.Equip:FireServer()
unequipped.Visible = false
equipped.Visible = true
end)
If player doesn’t has the gamepass, it will prompt to buy it, instead of executing the code above.
Can someone modify the code to make that happen?
Thanks!
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassId) then
-- Code Here
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(player,123456789)
end
local gamepassId = 000000 -- Add gamepass ID here.
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassId) then -- This will check if the player owns the gamepass.
-- Code Here
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(player,123456789) -- This will prompt the player purchase button.
end
I tested the local script like this and it didn’t work (didn’t execute the code or didn’t prompt to buy).
Probably i’m doing something wrong.
local gamepassId = 20269713 -- Add gamepass ID here.
local equipped = script.Parent.Parent.Equipped
local unequipped = script.Parent.Parent.Unequipped
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassId) then -- This will check if the player owns the gamepass.
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Halo5Remotes.Equip:FireServer()
unequipped.Visible = false
equipped.Visible = true
end)
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(player,20269713) -- This will prompt the player purchase button.
end
local gamepassId = 20269713 -- Add gamepass ID here.
local equipped = script.Parent.Parent.Equipped
local unequipped = script.Parent.Parent.Unequipped
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassId) then -- This will check if the player owns the gamepass.
game.ReplicatedStorage.Halo5Remotes.Equip:FireServer()
unequipped.Visible = false
equipped.Visible = true
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(player,20269713) -- This will prompt the player purchase button.
end
end)