How do i get all of the proximityprompts with getdescendants?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i just want to get all of the proximity prompts and make an equip script with all the tools in a folder

  1. What is the issue? Include screenshots / videos if possible!

How do I do this?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Is it a good idea to use model scripts or is it a good idea to use one script for all objects?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

MY SCRIPT

local Tools = game.Workspace.ToolFolder:GetDescendants()

for index, Tools in pairs (Tools) do
if Tools:IsA(“ProximityPrompt”) then

end

end

ProximityPrompt.Triggered:Connect(function(player)
print(“Tool active”)
end)

local Tools = workspace.ToolFolder:GetDescendants()
for i, objects in pairs(Tools) do
      if objects:IsA("ProximityPrompt") then
             objects.Triggered:Connect(function(Player)
                    print("Tool active")
            end)
      end
end

You could add triggered connection to the value.

1 Like