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

How to check if a player is in a certain team?

Asked by 3 years ago

Very simple question that I've completely lost myself to, got a server script that I use to allow a player to pick up an accessory, all of the script works except for the part that checks the players team.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Headlamp")

local ClickDetector = script.parent:FindFirstChild("ClickDetector")
game.Players.PlayerAdded:Connect(function(Player)
    print(Player.Name)
end)

local Teams = game:GetService("Teams")
local Hunters = Teams:FindFirstChild("Hunters")

ClickDetector.MouseClick:Connect(function(Player) 

    print('ClickRegistered')

    local Headlamp = script.Parent
    local Playername = Player.Name
    print(Playername)
    local Playeruser = game.Workspace:WaitForChild(Playername)
    local Humanoid = Playeruser:WaitForChild("Humanoid")

    if Playeruser:FindFirstChild("Headlamp") == nil then

        if Playername.Team == Hunters then

        Humanoid:AddAccessory(Headlamp)
        remoteEvent:FireClient(Player)
    end
    end


end)


I've tried but nothing happens, could someone tell me why?

0
Did it report any error? tuanorn 6 — 3y
0
No errors, just nothing happens at all CheeseBallGuy11 12 — 3y

Answer this question