Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this script only working in the stuido and not the actual game?

Asked by 4 years ago
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 answer

Log in to vote
-1
Answered by
Robowon1 323 Moderation Voter
4 years ago

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

0
the whole script is written so it runs serverside tho Fl3eandFlo3e 18 — 4y
Ad

Answer this question