here is my test script :
game.Workspace.test.Part2.ClickDetector.MouseClick:Connect(function(player) local a = 1 local b = a + a Print(b) end) game.Workspace.test.Part1.ClickDetector.MouseClick:Connect(function(player) local c = b + b Print(c) end)
somehow in the second function it is not recognizing the variable "b" even though i already put it on local on the first one
You could write the variable before the 2 function like this :
local a = 0 local b = 0 local c = 0 game.Workspace.test.Part2.ClickDetector.MouseClick:Connect(function(player) a = 1 -- Set a to 1 b = a + a -- Set b to a+a Print(b) end) game.Workspace.test.Part1.ClickDetector.MouseClick:Connect(function(player) local c = b + b -- set c to b + b Print(c) end)