i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 08:59 PM |
The player resets...?
The very first time a player joins the game it works but when they reset it doesn't load the value...
Here's the script.. Also, will FE cause anything to malfunction with this since I'm not using remote functions or remote events for this at all..
############################################################################################################################################### Player.CharacterAdded:connect(function(Character) local UserId = Player.UserId if not Player:FindFirstChild("Lazer Points") then local Val = Instance.new("IntValue", Player) Val.Name = "Lazer Points" Val.Value = LazerusPoints:GetAsync(UserId, LazerusPoints) print("[Value Loaded] Player Name: "..Player.Name.."") else Player["Lazer Points"].Value = LazerusPoints:GetAsync(UserId, LazerusPoints) print("Found") end local Val = Player:WaitForChild("Lazer Points") Val.Changed:connect(function() LazerusPoints:SetAsync(UserId, Val.Value) print("[Value Changed] Player Name: "..Player.Name.."") end) end) end)
game.Players.PlayerRemoving:connect(function(Player) local UserId = Player.UserId local LazerusPoints = Player:FindFirstChild("Lazer Points") LazerusPoints:SetAsync(UserId, LazerusPoints.Value) print("[Value Saved] Player Name: "..Player.Name.."") end)
|
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:00 PM |
| ################################################################################################################################################################################################################################ |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:01 PM |
| ######################################################################################## |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:02 PM |
My god... Roblox's censor system is way too OP... Apparently it's illegal to roblox to define datastores or do a simple playeradded event..
|
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:27 PM |
So confused about what could be wrong here.
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 09:29 PM |
i am too lazy to read all that so ima just give you pointers
GetAsync(KEY) returns the data stored on that key SetAsync(KEY,VALUE) sets the data stored on that key to that value
also you might want to just keep their data on a table like this
local playerdata = {}
--after getting data playerdata[tostring(Player.UserId)] = data
--this way you can access their data from the table with the string form of their UserId |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:34 PM |
Well.. u c, I'm an idiot so I don't know how 2 incorporate that into my code, also the "data" part because what is "data"
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 09:35 PM |
| ########################################### |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:38 PM |
lolol
I never work with tables so... I don't really see the big deal about putting it in a table since it's not like I'm gonna use it for anything.
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 09:39 PM |
| how else are you going to save someones data without having to GetAsync() on it every single time..? |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:41 PM |
Why not just GetAsync everytime someone resets or when a character is added.. Yes, the table way is a good way 2 go but not needed. Dude, it's not like my game is gonna get big so I'm just learning new scripting stuff slowly so all that important stuff is not really relevant to me right now
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 09:45 PM |
well your data will probably start to bug when GetAsync and SetAsync are being called multiple times
and if you can find someones data in the server you can limit your requests for things that really need it |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:46 PM |
Ok but, what does that "data" stand for? Lost right now.
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 09:50 PM |
| local data = GetAsync(KEY) |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:51 PM |
| ######################################################################################################################################################################################################################################################## |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:52 PM |
| ###################################################################################################################################################################################################################### |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:52 PM |
local PlayerData = {}
game.Players.PlayerAdded:connect(function(Player) table.insert(PlayerData, (tostring(Player.UserId))) end)
My god this filter is RIDICULOUS.
|
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:53 PM |
Am I on the right track or no...
|
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Aug 2016 09:57 PM |
if you dont want to use tables then dont im just saying there is a much more efficient way if you use them |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 09:59 PM |
:/
What about my original code.. Can you at least look at that?
I'd rather make it as reliable as possible than have random data losses sometimes.
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 10:02 PM |
http:// paste bin. com /MHa p6MGG |
|
|
| Report Abuse |
|
|
i_Movie
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 11725 |
|
|
| 29 Aug 2016 10:02 PM |
oml lately coding has not been working out for me. Like that struggled multiline chat thing.. I got it to work somewhat but it wasn't updating very fast when I typed something in.
Now I'm struggling to make a datastore that actually works.. :/ rip The struggle is real man
|
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 10:03 PM |
as you can see it only gets the data if there is not server data and if neither exist, it will be a default table
to edit the items in that table, simply get it using the player's user id (as a string) and edit the table |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 10:04 PM |
and also you need this
game.OnClose = function() wait(5) end
--will wait 5 seconds after all players leave before shutting down the server |
|
|
| Report Abuse |
|
|