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: Data store

Previous Thread :: Next Thread 
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:10 PM
So I am getting started with data store and I tried to make a script that would save if the player already joined the game before but it doesn't work. Can one of you, nerdy scripters help me?





game:GetService("DataStore S e r v i c e"):GetDataStore("Joined") -- Roblox censors S E R V I C E--


game.Players.PlayerAdded:connect(function(plr)

wait()


local key = "user_" .. plr.userId

ds:SetAsync(key,0)

local lel = ds:GetAsync(key)

if lel == 1 then

print (plr.Name.. "Has been here before")

elseif lel == 0 then
print (plr.Name.. "Has never been here before")
ds:SetAsync(key, 1)
end

end)

game.Players.PlayerRemoving:connect(function(plr)

local key = "user_" .. plr.userId

ds:SetAsync(key,1)

end)


Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
28 Feb 2017 04:12 PM
https://www.youtube.com/watch?v=PhtniVQbwlk

good practice for datastore ^ but for your solution why not just make a badge? unless this is for practice i suppose




Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
28 Feb 2017 04:15 PM
> "Can one of you, nerdy scripters help me?"

No need to put nerd in there. There's a strange tone in there.

> "game:GetService("DataStore S e r v i c e"):GetDataStore("Joined") -- Roblox censors S E R V I C E--"

Did you put the spaces in there when you were running it on your server? If so you need to remove the spaces (this means you copied it). If not, good catch to avoid the ROBLOX filters.

If it's not the spaces problem then we need more information. Are there any errors? How do you know it's not working?
Report Abuse
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:17 PM
@Wrath

It's for practice and I would not waste 100R since I'm already poor enough. Also on your video you should zoom in next time because it's hard to see.


Report Abuse
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:19 PM
@kools


It's simply not working. The output throws no error and when I come back to the game it does not say that the player has been here before... It says that he never has been here before.


Report Abuse
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:22 PM
And no I didn't spaced S E R V I C E in the studio.


Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
28 Feb 2017 04:24 PM
try setting it to a variable..

local ds =

because you're using ds:SetAsync and ds:GetAsync but ds is undefined


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx
Report Abuse
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:26 PM
Ah I forgot to put it in the forum but I did set it to a variable in studio.


Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
28 Feb 2017 04:28 PM
Every time you join you're using SetAsync to set the saved value to 0.


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx
Report Abuse
LightFantom is online. LightFantom
Joined: 23 Sep 2014
Total Posts: 7830
28 Feb 2017 04:31 PM
Thanks that was actually that.


Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
28 Feb 2017 04:31 PM
yep


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx
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