local numb = string.gsub(script.Parent.Name, "button", "")
local num = tonumber(numb)
num.Value -= 1
So basically I’m taking out the “button” from the script’s parent which is named “button5” so I can just have the number 5. Then you can see that I’m trying to turn it from a string to a number and then subtract 1, but it refuses to work no matter what I try. Any ideas on how to fix it?
Hi! Suppose your parent’s name is “button5”. In first line you’re removing “button” from the string, giving the variable numb a value of “5”. Then, you convert this “5” to an integer. Assigning the variable num the integer 5. Then, you’re attempting to change an integers Value for some reason? Integers are a data type and have no propierties. The propierty .Value are usually in IntValues, NumberValues, StringValues… However, in this script you’re dealing with an integer, not an Instance. The final script should be:
local numb = string.gsub(script.Parent.Name, "button", "")
local num = tonumber(numb)
num -= 1