Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

0
Thank you so much! You are a true helper! I was scrambling to find an answer and this surly helped! Icelogist 11 — 3y
Ad

Answer this question