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)
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