Hello. I am very new to Lua script, and it is very apparent that I am very bad at it. I am not sure if I should even be asking questions.
I am trying to change the value of the variable in this module script, using a script inside a button. But, it gives me this error. Why does it do this? Also, if necessary, I am making a clicking “simulator” game.
(ERROR)
Players.myName.PlayerGui.ClickGui.ClickButton.Script:5: attempt to perform arithmetic (add) on nil and number
moduleScript (ReplicatedStorage.myData)
local module = {}
myMoney = 1
return module
the button script (ClickGui.ClickButton.Script)
myMoney = require(game.ReplicatedStorage.myData)
function click ()
print("worked")
myMoney = myMoney.variable + 1
print(myMoney.variable)
end
script.Parent.MouseButton1Click:Connect(click)
Thank you