So in one script in a model, I set a value: health = 10 So then in a different script I want to change that for something and I try to get to the value like this: script.Parent.Parent.Script.health It didn't work. How do I get to values in other scripts?
✓ ANSWER ACCEPTED
How do I use values in other scripts?
1 answer
✓ Accepted answer
I would store them as int values or number values.
at the top of script do
a script in workspace named 'healthScript'
local health = Instance.new("NumberValue",script)
health.Name = "health"
health.Value = 10
health.Changed:connect(function () print(health.Value) end)
a script in workspace
workspace.healthScript.health.Value = 5
This should print 5
Update: was half asleep and workspace is a bad idea to store scripts however thanks for adark pointing it out!
** Just a tip, it is bad practice to put Scripts in the Workspace. It's much safer to put them in the ServerScriptService. ** ~ adark
2 comments
0
Just a tip, it is bad practice to put Scripts in the Workspace. It's much safer to put them in the ServerScriptService.
0
Yer I know, however instead of faking a path I just used workspace out of the flash. Thanks anyhow.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can either set the value to an IntValue or use Global Variables. In your other script put _G.health = 10 and then in the other script you wanna use it just do local health = _G.health and it should work fine.