So I already know how I can give abilities to players with stuff like swords, but now I want to know how
you can make a image button visible for only the player who owns the gamepass.
The issue is that when I try to make it it shows to all other players in the server.
Here’s the code;
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
local gamePassID = ********
local function onPlayerAdded(player) local hasPass = false local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) end) -- If there's an error, issue a warning and exit the function if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then print(player.Name .. " owns the game pass with ID " .. gamePassID) game.StarterGui.Menu.Menu2Frame.Selection.SelectionFrame.ImageButton.Visible = true end
–Connect “PlayerAdded” events to the “onPlayerAdded()” function