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?
Studio is client-side, game is server/client side, you can get around this using remotevents. https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events