Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 03:34 PM |
So I'm changing my game so that it works with FE. I have a problem with the DataStores now, I have my script to save everything and it all works perfect when I test it in studio, but in server when I click the save button it does nothing. If it helps, I store everything(all the values) in a Folder named Info in the player(on enter), this isn't leaderstats.
Here is the local script, in StarterGui.
script.Parent.MouseButton1Click:connect(function() game.ReplicatedStorage.RemoteEvents.SaveGame:FireServer() end)
Here is the normal script, in ServerScriptService(just an example).
RE.SaveGame.OnServerEvent:connect(function(Plr) if Plr:FindFirstChild("Info") then print("Saved! "..Plr.Name) local Info = Plr.Info local Pokeball = Info.Pokeball local T = {Balls = {Pokeball = 0;};} T.Balls.Pokeball = Pokeball.Value DataStore:GetAsync(Plr.userId,T) else print("Folder not found.") end end
It prints that it saved, but it does not save...
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
| |
|
|
| 23 Nov 2016 04:28 PM |
| The client can't save but the server can so just fire the server with a request and the server can choose to save if you allow it... |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 04:36 PM |
I'm sorry, I don't understand. I just started using RemoteEvents last night and I'm still not sure how they work exactly. Could you explain to me a little more on how I would do this, maybe walk me thru it?
|
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 04:54 PM |
Hey Briicks!
DataStore:GetAsync(Plr.userId,T)
GetSync is used to retrieve data from the store, use SetAsync(key,val) to save it.
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 04:56 PM |
Ik, I saw that... It was something I just wrote when posting and I was trying to get it done.
But that's not the problem.
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 05:07 PM |
I'm really in a hurry here, can someone please tell me what exactly I'm doing wrong...
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
| |
|
| |
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
| |
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
| |
|
|
| 23 Nov 2016 07:53 PM |
The Client can't directly access DataStores, only the Server can. RemoteEvents and RemoteFunctions create a sort of "communication line" between the Client and the Server. What you can do with that information is create a LocalScript that sends the data you want to save to the Server through a RemoteEvent, and then have the server save the data because it can access data stores.
You'll need this: http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent/FireServer
The player is automatically passed as the first argument when using FireServer(), so keep that in mind.
choo choo |
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 23 Nov 2016 07:56 PM |
I have tutorials on how REs work.
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow my twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 23 Nov 2016 08:03 PM |
also, a relevant reply:
>It prints that it saved, but it does not save...
No, it prints that "Plr:FindFirstChild("Info")" is true. You're using GetAsync, not Setasync.
DataStore:GetAsync(Plr.userId,T)
I suppose should be
DataStore:SetAsync(Plr.userId,T)
if you want to save T
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow my twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 08:37 PM |
Tbh you don't even really need to fire a RemoteEvent to save data, just do it within the data script. If you're using FilteringEnabled then it should already be compatible with the data script because its a serverscript and not local.
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 09:01 PM |
Wrathsong, read the prev replies before you assume that's my actual code.
|
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 23 Nov 2016 09:15 PM |
"Here is the normal script, in ServerScriptService(just an example)."
"Here is the normal script"
"HERE IS THE SCRIPT"
sorry I thought my assumption of your actual code was valid
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow my twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 09:37 PM |
"Here is the normal script, in ServerScriptService(just an example)." >(just an example) I wrote it but was in a hurry I had to go somewhere, I did that by mistake.
But mind linking to your tut of RE?
|
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 23 Nov 2016 10:07 PM |
yeah, check my sig for my channel and go to Playlists - it's there
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow my twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 11:00 PM |
Ok so, I got threw the first video. I'll keep watching but I have question. My actual save/load script works, but when the user goes to leave it gets the data the user came in with, how can I fix this? It works perfect in the non fe version, but not in fe.
Also can you get values from a folder you instance in the player upon enter from a normal script with fe on?
Someone should make a video on using data stores with fe so people can refer to it and see how it's done. People make videos but it's saying the exact something as another video. I watched soybean or w/e his name is tut on fe and it's just about the same as this, why not after you get the basics down make another video showing how to do different stuff?
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 23 Nov 2016 11:18 PM |
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=201595803 https://forum.roblox.com/Forum/ShowPost.aspx?PostID=200061209
Anyways,
--server
re.OnServerEvent:connect(function(plr,reason) if reason == 'Save' then DataHandler.SaveData(plr) --look in first link end end)
--client
re:FireServer('Save')
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 23 Nov 2016 11:21 PM |
Time I read over your thread, but could I not do this with a normal script inside of ServerScriptService instead of moving everything to a module script?
Why do you use a module script to do this, it it safer/better or something?
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 24 Nov 2016 12:00 AM |
So everything loads, and it also does save... But the problem is that it does not update to the new values when it saves, it saves the values they go into game with, can someone tell me why this is?
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Nov 2016 12:02 AM |
imo modules are better for everything you do
But yes, modules are safer, and more efficient in that you don't need to reuse code, and you keep code organized.
My example is simple. Please just be patient to understand it and follow my example.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Nov 2016 12:03 AM |
@Briick, the values need to be updated via the server
|
|
|
| Report Abuse |
|
|