example variable's value is "0" , localscript from startergui updates varibale to "1" and script from workspace.part takes the variable's value for something It looks like something like this:
Local variable = "0" --I don't know where to put this
for script 1 ; Script location : game.StarterGui ~~ Script Type : Local script
variable = "1"
for script 2 ; Script Location : game.Workspace.Part
game.Workspace.Part.ClickDetector.MouseClick:Connect(function(Player) Local Answer = variable + "1" print(variable.."+ 1 = " .. Answer) end)
the print should be "1 + 1 = 2
Lua is case sensitive, the datatype local
must be defined with a lowercase L. You can also use the global array _G
to store universal variables.
Lua will also perform the numerical operation with the two String expressions seen at line 2 of your second Script. This will result in a float 2.0
which will be concatenated into a result that looks like so: 2.0 + 1 = 2.0
.
I also highly suggest you leave numerical operations to numerical datatypes.
_G.Variable = 1
workspace.Part.ClickDetector.MouseClick:Connect(function() local Number = _G.Variable print(Number.." + "..Number.." = "..(Number + Number) end)