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)

4 comments
I wanted to make it so that it gets the player's team's name but this works, thanks!
Just compare player.Team to the team in TeamService. Teams:FindFirstChild() is one method.
Learn something new everyday, thanks Xpol.
or just do player.Team.Name facepalm