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

How do i make a script that edits the values of another script?

Asked by 6 years ago
Edited 6 years ago

Please explain in depth.

0
Can you please give us some more info about what you mean? Do you mean something like in 1 script, a = 0, but in another script, it changes it to a=5? User#20279 0 — 6y
0
The best thing i'd suggest is to use Remote Events with values. WindowsFireWalI 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

If both are Scripts or both are LocalScripts, you can use ModuleScripts (otherwise, look up RemoteEvents and RemoteFunctions - there's even guides on ScriptingHelpers at the top of the page).

ex:

--ModuleScript named "Module" in ReplicatedStorage
local module = {}
module.var = 0
return module

--Script 1
local module = require(game.ReplicatedStorage.Module)
module.var = 10
wait(1)
print(module.var) -- 20 because of what Script 2 does

--Script 2
local module = require(game.ReplicatedStorage.Module)
wait(0.5)
print(module.var) -- 10
module.Var = 20

Of note, you cannot change the value of a local variable in another script. That is, if Script #1 has local var = 5, you cannot change that value directly from a different script.

Ad

Answer this question