How to make a Proximity Prompt enabled to certain players who owns a certain gamepass?
You could use the .Enabled property in order to hide the prompt from the player. By default, the prompt could be hidden, and then you could enable it on the client depending on if the player owns the gamepass.
First, we would need to check if the player owns the gamepass:
local MarketplaceService = game:GetService("MarketPlaceService") local Player = game.Players.LocalPlayer -- check if the user owns the gamepass if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then -- we'll put our code here end
Then, we could enable the prompt on the client:
local MarketplaceService = game:GetService("MarketPlaceService") local Player = game.Players.LocalPlayer local Prompt = workspace.Part.ProximityPrompt -- check if the user owns the gamepass if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then -- enable the prompt! Prompt.Enabled = true end
Make sure to click on the links provided!
proximity prompt service script
local ProximityPromptService = game:GetService("ProximityPromptService")
-- Detect when prompt is triggered local function onPromptTriggered(promptObject, player)
end
-- Detect when prompt hold begins local function onPromptHoldBegan(promptObject, player)
end
-- Detect when prompt hold ends local function onPromptHoldEnded(promptObject, player)
end
-- Connect prompt events to handling functions ProximityPromptService.PromptTriggered:Connect(onPromptTriggered) ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan) ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)