Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ProximityPrompt visible to players who owns a gamepass?

Asked by 2 years ago

How to make a Proximity Prompt enabled to certain players who owns a certain gamepass?

2 answers

Log in to vote
0
Answered by
sngnn 274 Moderation Voter
2 years ago
Edited 2 years ago

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!

0
A question, what script would I use? Local Script or a regular script? I have tried with both script and both doesn't work. For the regular script it showed "attempt to index nil with 'UserId'" and for the local script, no errors showed but the prompt is still not enabled.   KevStarss 2 — 2y
0
LocalPlayer is only used on the client, so you would use a LocalScript. You may also be placing the script in the wrong place. sngnn 274 — 2y
0
So where would I put the script in? The ProximityPrompt? KevStarss 2 — 2y
0
LocalScripts don't run in workspace - you should put it in StarterPlayerScripts. sngnn 274 — 2y
0
Thank you so much for your help! KevStarss 2 — 2y
Ad
Log in to vote
0
Answered by
extrorobo 104
2 years ago

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)

0
I meant like if someone owns a certain gamepass, a proximity prompt becomes visible to that player. KevStarss 2 — 2y
0
yes, if someone earns a gamepass you then have to out this script under the gamepass extrorobo 104 — 2y
0
if your doubt has been cleared, please accept the answer extrorobo 104 — 2y
0
I reread the code. First of all, codeblocks... And this doesn't seem to answer the original question. sngnn 274 — 2y

Answer this question