Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make it so this script works only when a remote event is fired?

function D(p, o)
    while game.Workspace:findFirstChild(p).Humanoid do
        wait(0.5)
    end
    local n = game.Workspace:findFirstChild(p)
    if n ~= nil then
        n.UpperTorso.CFrame = CFrame.new(o)
    end
end

while true do
    wait(1)
    w = game.Workspace:children()
    for i = 1, #w do
        if game.Players:findFirstChild(w[i].Name) ~= nil then
            if w[i].Humanoid then
                p = w[i].Name
                o = w[i].UpperTorso.Position
                D(p, o)
            end
        end
    end
end

for example if a remoteserver is fired then the function activates

1 answer

✓ Accepted answer

Parent this script to a new script you made. Disable the old script. Set the new script contents to:

script.Parent.Remote.OnServerEvent:Connect(function()
script.Script.Disabled = false
end)

It's only a quick way to do it, but it works

This discussion is preserved as it was. New answers, comments, and votes are closed.