I'm working on a car garage in my game, and I want it so if any player is within 20 studs of the door, the brick is invisible, non-can-collide, and the decals are invisible. As of now, it works perfectly on single-player. But when multiple players are within the 20 stud radius, it breaks, permanently staying closed. What should I change to this existing script to make it work for multiple players?
while true do
local door = script.Parent
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character.Torso.Position - door.Position).magnitude <= 20 then
door.CanCollide = false
door.Transparency = 1
door.Decal.Transparency = 1
door.Decal2.Transparency = 1
else
door.CanCollide = true
door.Transparency = 0
door.Decal.Transparency = 0
door.Decal2.Transparency = 0
end
end
wait(0.3)
end
