Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Value change won't work

Asked by 10 years ago

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)
0
It won't work xXScorpianKillerXx 25 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

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)
Ad
Log in to vote
0
Answered by 10 years ago

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)
0
personally i'd do wait(3) then change 0.3 to 1 just to keep stuff at integers drager980 5 — 10y

Answer this question