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

How Do I Run Certain Function(s) That Are In Another Script?

Asked by 6 years ago

Okay so, basically I just have several functions doing different things in several different parts, although I'd just like to have one other script to tell them when to run at once if I can.

In more detail to try and explain if I haven't already: Several different parts in the workspace, all with their own script inside. They each have different functions inside those script.

Random examples to run at once:

local function playdisco
    while true do
        script.Parent.Brickcolor = Brickcolor.Random()
        wait(0.5)
    end
end
local function changetrans
    while true do
        script.Parent.Transparency = 0.5
        wait(0.5)
        script.Parent.Transparency = 0.9
        wait(0.5)
    end
end

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Use a RemoteFunction object, more info can be found here: Remote Events and functions. P.S consider using a coroutine if you're going to have more than one function at a time using a loop in the same script.

Ad
Log in to vote
0
Answered by 6 years ago
_G.playdisco = function()
    while true do
        script.Parent.BrickColor = BrickColor.Random()
        wait(0.5)
    end
end

just make a script and add this

_G.playdisco

do the same with changetrans

_G.changetrans = function()
    while true do
        script.Parent.Transparency = 0.5
        wait(0.5)
        script.Parent.Transparency = 0.9
        wait(0.9)
    end
end
_G.changetrans

Answer this question