Hi,
I was wondering if I can change the team a player is on once a ProximityPrompt is activated. I’ve looked around a bit and haven’t found a solution to my problem, and I’m relatively new to using ProximityPrompts but I really need to use one in this scenario. When activating the ProximityPrompt, the player that activated it should change teams. Any help would be greatly appreciated, and I’m so sorry if this is simple solution that I can’t find the answer to yet!
2 Likes
You should wait for the ProximityPrompt to finish and then change the Player.Team property.
ProximityPrompt.Triggered:Connect(function(player)
player.Team = game.Teams['TeamName']
end)
2 Likes
ProximityPrompt.Triggered have a parameters called “player”
that player is a player who triggered a proximityprompt
Something similar to this?
script.Parent.Triggered:Connect(function(player)
player.Team = game.Teams.Bronze
end)
edit: Just saw your changes.
1 Like
yea, by the way you can change player teamcolor too.
Yes, your script should work as long as this script is a child of the ProximityPrompt in question.
Good to know. Thanks for the info!
Yes it is. Thanks for the help guys!
You can check if player:IsInGroup(id: number)
returns true for group checking.
1 Like
Read the docs for this kind of stuff in order to not stray off-topic from the OP. You can create a new event listener for a new ProximityPrompt and reset the Player.Team
and Player.TeamColor
properties and use :TakeDamage(math.huge)
to kill.
I could, but you should learn the APIs yourself so you can get a better understanding of Luau and understand how and why this ProximityPrompt situation works.
For the overall structure, you would need an event listener for the specific proximity prompt. In the callback, you should get the player object and set the Team and TeamColor properties to nil. For respawning, just kill the player.