So, I have this function right here.
BotUp.Button.MouseButton1Click:connect(function() if BotUp.ImageColor3 == Color3.fromRGB(255,255,255) then if Level.Value >= BottomUpgrade.Level.Value then if Cash.Value >= BottomUpgrade.Cost.Value then UpgradeEvent:FireServer(LocalPlayer,TOWER,"Bottom") end end end end)
It works pretty well. However, I cannot change the variable TOWER from outside of the function and let it take effect inside of the function. If there is a way to do what the function does above and let the rest of the script change TOWER and let it take effect, please tell me! I would be massively thankful!
You could declare TOWER
as a global variable, in that state all modifications made to it will apply throughout wherever it's called upon, and can even be modified within a function itself.
local TOWER = -- Change this to what you desire and it'll apply below BotUp.Button.MouseButton1Click:Connect(function() UpgradeEvent:FireServer(TOWER, "Bottom") -- Player sent by default end)