|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 28 Feb 2017 04:31 PM |
Thanks that was actually that.
|
|
|
| Report Abuse |
|
|
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 |
|
|