Sorry to bump this in late, but Friendly Fire/Team Killing does not seem to work. I tried adding string values in every player character, which did work, but I could still kill my teammates. There were only 2 methods that gave the string values in every player character, and here are the scripts:
Method 1 (ServerScriptService):
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local RedColor = BrickColor.new("Really red")
local BlueColor = BrickColor.new("Toothpaste")
if plr.TeamColor == RedColor then
local RedString = Instance.new("StringValue", char)
RedString.Name = "Role"
RedString.Value = "Red"
elseif plr.TeamColor == BlueColor then
local BlueString = Instance.new("StringValue", char)
BlueString.Name = "Role"
BlueString.Value = "Blue"
end
end)
end)
Method 2 (StarterCharacterScripts):
local Teams = game:GetService("Teams")
local RedTeam = Teams.RedTeam
local BlueTeam = Teams.BlueTeam
local RedColour = BrickColor.new("Really red")
local BlueColour = BrickColor.new("Toothpaste")
for _, redPlr in pairs(RedTeam:GetPlayers()) do
local redChar = redPlr.Character
if redPlr.TeamColor == RedColour then
local RedString = Instance.new("StringValue", redChar)
RedString.Name = "Role"
RedString.Value = "Red"
end
end
for _, bluePlr in pairs(BlueTeam:GetPlayers()) do
local blueChar = bluePlr.Character
if bluePlr.TeamColor == BlueColour then
local BlueString = Instance.new("StringValue", blueChar)
BlueString.Name = "Role"
BlueString.Value = "Blue"
end
end
I’m really not sure if i did something wrong, because I can see the string value in the character with the correct name and value. I’ve been struggling with this for a while now. Any help is appreciated.