I am making a Cookie Clicker game, and I am trying to make it so if a Player has 100 Cookies, they can buy an Option to get automatic cookies, but I am having troubles on it. The first line has an error, for the "if script.Parent.Parent.Parent.Cookies.Number.Value = 100 then" part. Here is the script:
function onClicked() if script.Parent.Parent.Parent.Cookies.Number.Value = 100 then while true do script.Parent.Parent.Parent.Cookies.Text = script.Parent.Number.Value script.Parent.Parent.Parent.CPS.Number.Value = script.Parent.Parent.Parent.CPS.Number.Value + 0.3 script.Parent.Parent.Parent.CPS.Text = script.Parent.Parent.Parent.CPS.Number.Value end script.Parent.MouseButton1Click:connect(Click)
Here, let me fix this up:
function onClicked() if script.Parent.Parent.Parent.Cookies.Number.Value == 100 then while true do script.Parent.Parent.Parent.Cookies.Text = tostring(script.Parent.Number.Value) script.Parent.Parent.Parent.CPS.Number.Value = script.Parent.Parent.Parent.CPS.Number.Value + 0.3 script.Parent.Parent.Parent.CPS.Text = tostring(script.Parent.Parent.Parent.CPS.Number.Value) wait() end end end script.Parent.MouseButton1Click:connect(onClicked)
Make sure your CPS value isn't an intvalue because integers don't go into decimals also == 100 not = 100 == means "is equal to" as a question = means simply put "is" also fix on your script
function onClicked() if script.Parent.Parent.Parent.Cookies.Number.Value == 100 then while true do wait(1) script.Parent.Parent.Parent.Cookies.Text = script.Parent.Number.Value script.Parent.Parent.Parent.CPS.Number.Value = script.Parent.Parent.Parent.CPS.Number.Value + 0.3 script.Parent.Parent.Parent.CPS.Text = script.Parent.Parent.Parent.CPS.Number.Value end end end script.Parent.MouseButton1Click:connect(Click)