How do I make this script apply to a certain team only? I would be very thankful if anybody can help out!
local UIS = game:GetService('UserInputService') local plr = game.Players.LocalPlayer local Char = plr.Character or plr.CharacterAdded:Wait() local Key = 'Q' --Change this to Desired Letter. UIS.InputBegan:Connect(function(Input, IsTyping) if IsTyping then return end local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] then print(plr.Name..' has pressed '..Key) game.StarterPack.Sound:Play() --Make sure that your Sound is named 'Sound' and inside the Workspace. end end)
All you'd have to do is use an if statement to check their team.
Like so:
local UIS = game:GetService('UserInputService') local plr = game.Players.LocalPlayer local Char = plr.Character or plr.CharacterAdded:Wait() local Key = 'Q' --Change this to Desired Letter. UIS.InputBegan:Connect(function(Input, IsTyping) if IsTyping then return end local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] and plr.Team == game.Teams.Team1 then print(plr.Name..' has pressed '..Key) game.StarterPack.Sound:Play() --Make sure that your Sound is named 'Sound' and inside the Workspace. end end)