generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why doesn't this work? At all?

Previous Thread :: Next Thread 
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 07:58 PM
local datastore = game:GetService("DataStoreService"):GetDataStore("HamburgerMewMeow932239")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("NumberValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local promotion = Instance.new("NumberValue")
promotion.Name = "BlueCash"
promotion.Parent = leaderstats
local salary = Instance.new("NumberValue")
salary.Name = "GreenCash"
salary.Parent = leaderstats
local cash = Instance.new("NumberValue")
cash.Name = "Cash"
cash.Parent = leaderstats
local userid = plr.userId
local hasdata = datastore:GetAsync("cash"..userid)
if hasdata == false then
cash.Value = 500
datastore:SetAsync("cash"..userid, {cash.Value})
else
cash.Value = hasdata[1]
end
local hasdata2 = datastore:GetAsync("salary"..userid)
if hasdata2 == false then
salary.Value = 5
datastore:SetAsync("salary"..userid, {salary.Value})
else
salary.Value = hasdata2[1]
end
local hasdata3 = datastore:GetAsync("promotion"..userid)
if hasdata3 == false then
promotion.Value = 0.05
datastore:SetAsync("promotion"..userid, {promotion.Value})
else
salary.Value = hasdata3[1]
end
end)

game.Players.PlayerRemoving:Connect(function(plr)
local userid = plr.userId
local promotion = plr.leaderstats.BlueCash
local cash = plr.leaderstats.Cash
local salary = plr.leaderstats.GreenCash
local promotable = {promotion.Value}
local saltable = {salary.Value}
local cashtable = {cash.Value}
datastore:SetAsync("promotion"..userid, {promotion.Value})
datastore:SetAsync("salary"..userid, {salary.Value})
datastore:SetAsync("cash"..userid, {cash.Value})
end)
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:00 PM
b
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Nov 2017 08:00 PM
You tell us, what are the errors?
Report Abuse
NoobXWatch is not online. NoobXWatch
Joined: 03 Sep 2017
Total Posts: 2
10 Nov 2017 08:02 PM
Probally one mistake error in it Check Carefully.
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:06 PM
I rejoin my game, and I get 500 money, # ######### # ########## and nothing has saved
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:07 PM
You should really tell me how to fix this blob of code
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:11 PM
b
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:13 PM
bb
Report Abuse
SlimeMan22 is online. SlimeMan22
Joined: 10 Mar 2012
Total Posts: 1210
10 Nov 2017 08:13 PM
From the wiki:
>Data is also saved as a string in data stores, regardless of its initial type.

Šçrätčh ïïś ƒö® łëvëł 17 äñöñ DÖŠ HTMŁ hæx0rs whö üsë ŚQŁ++ ïïńśpëçt ëłæmęñtïïñg
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
10 Nov 2017 08:14 PM
Stop bumping and posting if you have no idea how it errors. If you aren't going to help us understand your issue, we're not even going to try.

You need to tell us three things.
1: What is this script supposed to do?
2: What is this script doing?
3: What are the errors in the output? / Where does it stop printing?
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:16 PM
1: What is this script supposed to do?
It's supposed to make values for currencies and load and save them.
2: What is this script doing?
Making the currencies, but doing no loading. Green/blue cash just becomes 0, regular cash becomes 500. It's weird.
3: What are the errors in the output? / Where does it stop printing?
No errors in the output, but i'll try prints.
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:18 PM
help pls
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:22 PM
i said help
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:24 PM
h e l p
Report Abuse
Criticrystal is not online. Criticrystal
Joined: 02 Jan 2016
Total Posts: 8793
10 Nov 2017 08:38 PM
pls already
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
11 Nov 2017 06:35 AM
It's a ##### of clutter, you really shouldn't be storing things in this way. Also you setasync like a trillion times back to back- you should try to bundle those into a single setasync because, yes, there is a limit The key in the datastore should be the player.UserId (note UserId is caps, userId is deprecated), and its value should be a table containing all this data. Also instead of generating each leaderstat value object, you should just clone a folder containing all of them preset so you don't have to create each one
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
11 Nov 2017 06:39 AM
It's a lot of clutter, you really shouldn't be storing things in this way. Also you setasync like a trillion times back to back- you should try to bundle those into a single setasync because, yes, there is a limit

The key in the datastore should be the player.UserId (note UserId is caps, userId is deprecated), and its value should be a table containing all this data.

Also instead of generating each leaderstat value object, you should just clone a folder containing all of them preset so you don't have to create each one
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image