You cannot access the LocalPlayer from the server, only on the client. Instead you would need to do something like this...
local Safe = game.Teams.Safe
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if player.Team == Safe then
local forcefield = Instance.new("ForceField")
forcefield.Name = "NewForceField"
forcefield.Parent = character
end
end)
end
Alternatively this may not work due to the team being assigned when the character already exists, so you could also do something like this...
local Safe = game.Teams.Safe
game.Players.PlayerAdded:Connect(function(player)
player:GetPropertyChangedSignal("Team"):Connect(function()
if player.Team == Safe then
if player.Character then
local forcefield = Instance.new("ForceField")
forcefield.Name = "NewForceField"
forcefield.Parent = player.Character
end
end
end)
end
1 comment
Thanks ! The first script worked for me with a bit of editing, you forgot a parenthesis at the last end