Detecting player's team

I am making a ProximityPrompt that will only work if a player is in a certain team but i can’t manage to get it to work.

script.Parent.Triggered:Connect(function(plr)
	if plr.TeamColor == game.Teams.Cientista.TeamColor then
		print("in team")
	else
		print("not in team")
	end
end)

Besides team color i have also tried the Team Instance in game.Teams.

I don’t see any mistakes in this code. Are you trying to only show the prompt to the correct team? Or all teams should see it but only one can use it?

All can see it but only one can use it

Well then a simple if statement like the one you posted should do the job.

Yea, but the problem is it’s not working.

Probably on line 2

I can’t see any issues in this code. What exactly doesnt work in it?

Every time i finish the pp it just says player is not on team, so the error is mostly on detecting the player’s team

Edit: Same thing happened when i used if plr.Team = game.Teams.Teamname

Is this a normal script? Also how are you changing the player’s team?

I have been changing player’s team through studio, just selecting it manually. And yes it’s a normal script.

When you change the player’s team or generally anything manually, it by default is changed like in a local script. Therefore, serverside stuff cannot see this change. Try clicking the “Client” thing on the topbar while in testing mode to switch to server mode and then you should be able to apply changes normally.

2 Likes