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

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

Please explain in depth.

2 comments

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?

0

The best thing i'd suggest is to use Remote Events with values.

1 answer

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.

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