Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Whats wrong with this script?

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

✓ Accepted answer

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.

1 comment

0

Works, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.