Hi,
I ran into a problem while using proximity prompts. I attach one to every player for trading, but also use it for other things like to arrest people when you’re a cop. And I don’t know how to make the text pop up as trade for civilian but for police show arrest. I guess I can make a local script that loops for each player and does that but it doesn’t seem good nor efficient.
It’s probably better to use entirely separate ProximityPrompt objects and set Enabled based on context. The idea is essentially: one action → one prompt. If you have multiple different actions, use multiple prompts. If an action isn’t relevant, disable its prompt.
Well, but isn’t in the same thing as changing the name? You still have to do some loops to make it works whenever other people reset and stuff.
I’m not sure I understand your problem. The main benefit to using separate prompts is that you can set them up individually (object and action text, function that’s connected to Triggered, etc). The only thing that remains is setting Enabled on the one that is relevant.
I have a script that manages the triggered events depending on your team, all I want is to change proximity prompt’s action text depending on the team the player is on.
prompt = script.Parent
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
if player.Team.Name == "Red" then
prompt.ActionText = "Red team!"
elseif player.Team.Name == "Blue" then
prompt.ActionText = "Blue team!"
end
end)
prompt.Triggered:Connect(function(player)
print("Prompt triggered by "..player.Team.Name.."!")
end)
Relatively simple to achieve this.