You could achieve what OP is asking for by using ProximityPromptService. This would cut out the need to use CollectionService. Specifically you would want to use the PromptTriggered event (it returns the prompt instance, and the player who fired the prompt.)
There’s also other events that can be used to detect when input is ended and when input to a prompt starts.
Well not affect multiple parts, I just want to get collectionservice to do stuff to the player without having to do SO many scripts of the same code e.g: Change a player’s currency when triggering a prompt.
You don’t need to use CollectionService for this. What you want is something along the lines of this:
local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.PromptTriggered:Connect(function(Prompt, Player)
-- this event will get fired when ANY proximity prompt gets triggered, you only need 1 script
-- you could modify the players currency here by checking what kind of prompt it is
end)
Then in this case, yes, do as @v7zr suggested and use PromptTriggered. You can use CollectionService to check if the Prompt is supposed to handle currency, such as tagging it with “CurrencyPrompt”.
DO NOTE YOU ONLY NEED ONE SCRIPT IN THE ENTIRE GAME FOR THIS. Ideally you could name the ProximityPrompt for the action it does, or create a StringValue object within the prompt and assign it a value of what it does.
local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.PromptTriggered:Connect(function(Prompt, Player)
if not Prompt:FindFirstChild("Action") then return end -- looks for an object named "Action" within the prompt
if Prompt.Action.Value == "Cash" then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 10
end
end)