I'm not sure why its not working, i'm trying to make it so when you're close to distance it gives you a force shield and when you're not close to the distance it removes your force shield..
distance = 50
while true do
for i,v in pairs(game.Players:GetChildren()) do
human = v.Character:FindFirstChild("Torso")
if human ~= nil and (script.Parent.Position - human.Position).magnitude <= distance then
while (script.Parent.Position - human.Position).magnitude <= distance do
script.Parent.BrickColor = BrickColor.new("Bright red")
local Check = v.Character:FindFirstChild('ForceField')
Check:Destroy()
wait(0.04)
end
wait(0.04)
local ForceField = Instance.new('ForceField', v.Character)
script.Parent.BrickColor = BrickColor.new("Bright green")
end
wait(0.04)
end
wait(0.04)
end

2 comments
you realize you have nested while loops, right...
Yes.