local distance = 2000
local function locate(plr)
local far = (script.Parent.Position - plr.Character:FindFirstChild("Torso").Position).Magnitude
if far < distance then
script.Parent.CFrame = CFrame.new(script.Parent.Position,plr.Character:FindFirstChild("Torso").Position)
end
end
local function find()
local plrs = game.Players:GetPlayers()
for i = 1,#plrs do
local plr = plrs[i]
locate(plr)
end
end
while true do
wait(.1)
find()
end
This code works in the studio but not in game. Why would this be?

1 comment
the whole script is written so it runs serverside tho