I’m making a codes and spins system, when the player writes “betacode” in the text box, he receives 2000 spins, however, I’m receiving this error when typing the code:
“attempt to perform arithmetic (add) on nil and number”
Here is my code with some more useful explanations:
spinsValue = 5 --this is the initial spins value
print ("spins: " .. spinsValue) --[[ here I know that the spins value
is not nil because it prints "spins: 5" ]]--
script.Parent.FocusLost:connect(
function(enterPressed)
if enterPressed then
print(script.Parent.Text)
local code = (script.Parent.Text)
if code == "betacode" then --"betacode" is the code that needs to be entered to earn 2000 spins.
_G. spinsValue = _G. spinsValue + 2000 --here is the error
end
end
end
)
if spinsValue >= 2000 then
print ("spins: 2000")
end