New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 10 days 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 10 days 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 — 8d
Ad

Answer this question