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?
I would store them as int values or number values.
at the top of script do
a script in workspace named 'healthScript'
1 | local health = Instance.new( "NumberValue" ,script) |
2 | health.Name = "health" |
3 | health.Value = 10 |
4 |
5 | health.Changed:connect( function () print (health.Value) end ) |
a script in workspace
1 | 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