I wanted to make a system that only people from a certain team can execute a function.
Here's what I have (It doesn't work and no error message shows up in the output):
local UIS = game:GetService("UserInputService") local players = game:GetService("Players") local player = players.LocalPlayer local function getKey(input) if input.UserInputType == Enum.UserInputType.Keyboard then local keyPressed = input.KeyCode if keyPressed == Enum.KeyCode.E then print("The player pressed E!") if player.Team == "Killer" then print("The player is a killer!") end end end end UIS.InputBegan:Connect(getKey)
Use BrickColor/TeamColor to get the team a player is on.
local UIS = game:GetService("UserInputService") local players = game:GetService("Players") local player = players.LocalPlayer local function getKey(input) if input.UserInputType == Enum.UserInputType.Keyboard then local keyPressed = input.KeyCode if keyPressed == Enum.KeyCode.E then print("The player pressed E!") if player.TeamColor == BrickColor.new("Bright red") then print("The player is a killer!") end end end end UIS.InputBegan:Connect(getKey)