Proximity Prompt activating all prompt scripts

So I’m trying to make a snowboard game and I set up the Proximity prompts but when I activate one of the prompts it activates all of them. How could I fix this?

https://gyazo.com/3d049ead4c3a1a91d38482830a31864f

local ProximityPromptService = game:GetService("ProximityPromptService")

local function onPromptTriggered(promptObject, player)
		print(player.Name.. " mounted CoDev board")
end

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

That’s the script for every proximity prompt.

2 Likes

The PromptTriggered event of the ProximityPromptService will listen for any ProximityPrompt in the game to be activated. If you’d like to continue using that, you could add in conditional statements that will check which prompt was activated and fulfill a specific action based on that.

Otherwise, if you’re looking to do this on an individual level, I’d suggest utilizing the Triggered / TriggerEnded events of the specific ProximityPrompt Instance you want to listen for:


Examples

ProximityPromptService

local ProximityPromptService = game:GetService("ProximityPromptService")

local function onPromptTriggered(promptObject, player) -- promptObject refers to the specific ProximityPrompt that was activated
    if promptObject.Name == "SnowboardPrompt" then -- Checks for the name of the prompt before doing something
        -- Activate another function/do something related to the Snowboards

    elseif promptObject.Name == "DoorPrompt" then -- If its name was "DoorPrompt", for example
        -- Same as above, except for something related to the functionality of a door
    end
end

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered) -- Whenever any Prompt in the game is activated, the function called "onPromptTriggered" will be run

Individual ProximityPrompt

local ProximityPrompt = script.Parent -- References a specific ProximityPrompt

local function onPromptTriggered(player)
    -- Because you know which prompt is being referred to, you can immediately continue
end

ProximityPrompt.Triggered:Connect(onPromptTriggered) -- Whenever the referenced prompt has been activated, it'll run the function called "onPromptTriggered"

Resources

Additional information can be found on the Roblox Developer Hub:

ProximityPrompt Documentation

ProximityPrompt Article

3 Likes

I tried this and I only seemed to get one board working but the others are not working

Never mind found my error and managed to fix it, Thank you so much!

1 Like