Hello, I’m having trouble making a DataStore and I have no idea how to start. It’s for a cookie clicker game, and I’m trying to save the amount of cookies (cookies is a variable.) I’m new to DataStores, I’ve tried looking through developer.roblox.com, however it did not help much. Any help will be appreciated.
Since my “cookies” variable is in a localscript, is there a way to send it to a server script?
Oh yeah, that completely slipped my mind. Thanks!
I’ve run into another problem. So the way my code works is when the player joins, the server fires a RemoteEvent and the Client receives it. The parameter is the value of the Cookies. However, how CookieClicker works is when you click, it adds to your stats. How would I make it so, it would get your leaderstats, in this case cookies, and when you click it adds to the leaderstats? Before I had to add the DataStore, I did this:
while wait() do
player.leaderstats.Cookies.Value = cookies
end
However, I can no longer use that as the current cookie count will overwrite the data.
(Thanks in Advance!)
What’s the ‘CookieClicker’ you mentioned, a GUI, a part with a ClickDetector, a ProximityPrompt…?
It’s an image button.
(By the way, by “CookieClicker” I meant the original game, this is simply a remake)
Oh alright. Well for that you can just detect the click on the server, there’s no need to check it on the client. Just make it so everytime the ImageButton is clicked (MouseButton1Click
) add an X amount (which you decide) to the cookies.
There’s also a textlabel which displays the person’s current cookie count, is there a work-around to it?
Yes, you can set the text of it with the Text
property. Do something like TextLabel.Text = Player.leaderstats.Cookies.Value;
(You can remove the semicolon at the end, I just like to use them)
Would it still show the Client their own cookie count?
Oh wait, it would. I forgot lol