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

1 comment
Local defines the variable as singular to its scope; it will only be understood in which block it is defined in. Unfortunately, you cannot create global variables within functions, so you’ll have to define b outside the function scopes.