I have a script that checks if you on the correct team then executes a code
in the output it says
ServerScriptService.Script:6: attempt to index nil with 'Team'
This is the script
local players = game:GetService("Players")
local plrr = game.Players.LocalPlayer
local LeftFoot = game.ServerStorage.Folder.LeftFoot.Middle
local LeftFoot2 = game.ServerStorage.Folder.LeftFoot.part
local function onCharacterAdded(character)
if plrr.Team == game.Teams.test then
local plr = game.Players:FindFirstChild(character.Name)
local clone = LeftFoot:Clone()
clone.Parent = character.LeftFoot
local clone = LeftFoot2:Clone()
clone.Parent = character.LeftFoot
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
players.PlayerAdded:Connect(onPlayerAdded)
Ok so that is the issue. Local player can only be used from a local script, can you retrun the players name when they enter the game and call “OnCharacterMade” with the players name then you should be able to just do
As @XmcElectricity said LocalPlayer doesn’t exist on server and will return nil so you need to remove that line
Now in here (above if statement) you should create a variable with named plrr and assign this value to plrr variable: game.Players:GePlayerFromCharacter(character)
it should look like this:
local players = game:GetService("Players")
local LeftFoot = game.ServerStorage.Folder.LeftFoot.Middle
local LeftFoot2 = game.ServerStorage.Folder.LeftFoot.part
local function onCharacterAdded(character)
local plrr = game.Players:GetPlayerFromCharacter(character)
if plrr.Team == game.Teams.test then
local clone = LeftFoot:Clone()
clone.Parent = character.LeftFoot
local clone = LeftFoot2:Clone()
clone.Parent = character.LeftFoot
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
players.PlayerAdded:Connect(onPlayerAdded)