I’m in the middle of coding an invincibility system, and instead of doing something complicated I rather use forcefields. The problem is the script doesn’t seem to give the forcefield
Script:
for _, v in ipairs(players) do
local ff = Instance.new("ForceField")
ff.Visible = true
ff.Name = "ForceField"
ff.Parent = v.Character
debris:AddItem(ff, 1000000000)
end
Here are a few things you can check to troubleshoot the problem:
Ensure that the players variable contains the desired players you want to apply the force fields to. You can print the players variable to verify if it contains the correct player objects.
Confirm that the Character property of each player is not nil. If a player’s character hasn’t loaded yet, the Character property will be nil, and you won’t be able to parent the force field to it. Make sure you’re applying the force field after the character has been fully loaded.
Fixed it. It was because :GetPlayers gives an array of the players when the server starts, and not when it’s called. Just wait to use :GetPlayers until you actually need it