I'm making a function that can be called from the main module to the GUIHandler when the player clicks the purchase button in the GUI. This function is supposed to (when the player clicks the button) confirm that the player has enough currency to purchase the item, then decreases the amount of the player's currency by whatever the item price is. For some reason I am getting an error stating that I need a function call after "then"
local function Purchase() if Plr.DataLog.Cubits.Value >= 10 then Plr.DataLog.Cubits.Value - 10 --This line is where the error is occurring. else print("Insufficient Funds") end
I am really stumped at this. Any advice will be great, thanks!
Simple fix, not really sure how to explain this but, here's the answer:
local function Purchase() if Plr.DataLog.Cubits.Value >= 10 then Plr.DataLog.Cubits.Value = Plr.DataLog.Cubits.Value - 10 --This line is where the error is occurring. else print("Insufficient Funds") end
If anyone has a way to explain to this, post a comment under this answer.
You need an end for the if statement:
local function Purchase() if Plr.DataLog.Cubits.Value >= 10 then Plr.DataLog.Cubits.Value - 10 --This line is where the error is occurring. else print("Insufficient Funds") end <--- Another end end
You have an end for the function but not for the if loop, which might be why it is not working/you have an error.