Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to check a player's team with a click detector?

I am trying to make a capturing mechanic to kill a player when a different team clicks on them. I have tried multiple times to make the script. Am I doing something wrong? Please let me know! (The click detector is in the Torso)

function onClicked(player)	
a = game:GetService("Players"):GetPlayerFromCharacter(onClicked.Parent)
	if (a) then
		if (a.TeamColor == BrickColor.new("Really blue")) then
			script.Parent.Parent.Parent.Humanoid.Health = 0
		end	
	end	
end
  
script.Parent.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

Yes, it is

as we know clickdetectors pass the player value

so we can simply:

script.Parent.MouseClick:Connect(function(player)
print(player.Team) -- you can also check the player team
	if player.Team.Name == "INSERT TEAM NAME HERE" then
		print("his team is".. player.Team.Name)
	end
end

btw, connecting function instantly is alot easier

see if this helps

1 comment

0

Thank you so much! You are a true helper! I was scrambling to find an answer and this surly helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.