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

Whats wrong with this script?

Asked by 10 years ago

So, i'm making a cookie clicker game, and this script does not work...

Also i have 3 leaderstat values, CPS (Cookies per Second) CPC (Cookies per Click) Cookies

ok heres the script:

Player = game.Players.LocalPlayer
CPS = Player.leaderstats.CPS.Value
Cookies = Player.leaderstats.Cookies.Value


while true do
Cookies = Cookies + CPS
wait(1) 
end

1 answer

Log in to vote
0
Answered by
Tiranin 45
10 years ago

What you did is make variables CPS and Cookies simply numbers. CPS and Cookies need to represent an object:

Player = game.Players.LocalPlayer
CPS = Player.leaderstats.CPS
Cookies = Player.leaderstats.Cookies


while true do
    Cookies.Value = Cookies.Value + CPS.Value
    wait(1) 
end

What you did is that Cookies was a number. For example, if Cookies (stat) had a value of 10, then Cookies (variable) would be 10, same for CPS. Then, you added CPS (etc. 2) to Cookies, making it 12, 14, 16, and so on. It didn't change any of the values because the variables were Numbers, not Objects. You simply took the values of objects and calculated with them.

When you define object to a variable, you can strictly tell him what the value is and will be.

0
Works, thanks! starkiller523 65 — 10y
Ad

Answer this question