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 problems, please help

Previous Thread :: Next Thread 
KarthonTulliusEnnius is not online. KarthonTulliusEnnius
Joined: 30 May 2010
Total Posts: 230
03 Jun 2015 09:01 AM
http://pastebin.com/YatJKHWa
This is my script, It's supposed to create a stats model and intvalue as children under the player which is working fine. But it's also supposed to store the player stats when they leave the server and reload them when the player rejoins. I don't know why it's not working, in studio it works fine, but when I rejoin the server on it's own, it says the server has shut down, I assume it's some bug with my data store, can anybody help?
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:04 AM
first two questions.

1. the script you pastbinned, path to it please?

2. is it a localscript or a serverscript?

there's alot of mistakes with this in studio mode, hence why i'm asking.
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:05 AM
oh, i also want to know wheter FilteringEnabled is turned on. (property of Workspace.)
Report Abuse
KarthonTulliusEnnius is not online. KarthonTulliusEnnius
Joined: 30 May 2010
Total Posts: 230
03 Jun 2015 09:07 AM
This is one large script right in the workspace, so a server script I guess, I am a bit of a newbie. Also FilteringEnabled is not turned on, what does it do?
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:12 AM
FilteringEnabled restricts localscripts' acces to server content and server scripts acces to client content. this is pretty much a way to make your game exploit-proof, but requires alternative scripting and custom networking to make everything work. i only advise using FilteringEnabled once you've got a firm grip of Lua.

about the 'server script' thingy, aslong as it is not a 'localscript' object it is recognized as a server script by roblox.


your script location seems to be fine, so checking the pastbin now.

lastly, if you ever have any other questions, feel free to contact me, i am always willing to help you with the lua API should you want it.
Report Abuse
KarthonTulliusEnnius is not online. KarthonTulliusEnnius
Joined: 30 May 2010
Total Posts: 230
03 Jun 2015 09:16 AM
Alright I appreciate it, let me know if you see any errors or possible bugs in my script, thanks.
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:24 AM
i have found a few things which could be causing your problem.

first of all, game.Players.PlayerRemoving is fired only when a player disconnects through esc->disconnect, and does not handle crash/force-quits like pressing the red X or literally getting a client crash. instead, use game.Players.ChildRemoved().

secondly, there is a change the networking priorities of roblox cause the player object to be removed before your script can even acces the player, for that reason, i advise storing player data somewhere else. ive changed this to Workspace, but you could put it anywhere.

thirdly, you are waiting until a player's data is ready when he is actually being removed.
the only reason this works in studio is because of the zero network latency, which you DO experience on a normal server.

lastly, because of risks with the last player leaving, i also advice saving the data on a regular interval, for example every 10 seconds.

here's a new pastebin, which SHOULD work.

http://pastebin.com/HwBg3U4D

Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:28 AM
oops, i forgot adding a save every 10 seconds, you could do this by adding this outside the current function:


if workspace:FindFirstChild("Stats") then
while true do
wait(5)
for i,v in pairs(workspace.Stats:GetChildren()) do
a = v.Gold.Value
DataStore:SetAsync(v.Name,a)
end
end
end
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:28 AM
above is for 5 seconds, i think its clear how to change this.
Report Abuse
KarthonTulliusEnnius is not online. KarthonTulliusEnnius
Joined: 30 May 2010
Total Posts: 230
03 Jun 2015 09:33 AM
Will the saving work, I noticed it's

Workspace:findFirstChild("Stats")

when stats are inside of the player, would this still work?
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:38 AM
oops, supposed to be FindFirstChild.

i moved stats from player to workspace because of reason 2 in my previous posts.

see top of my own new pastebin.

local stats = Instance.new("Model")
stats.Name = "Stats"
stats.Parent = workspace

and when a player joins,

local plrstats = Instance.new("Model")
plrstats.Name = player.Name
plrstats.Parent = stats

therefore, you get a model structure like this:

-Workspace
--Stats
---Player 1
----Gold
---Player 2
----Gold
---Player 3
----Gold
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
03 Jun 2015 09:40 AM
the reason i'm actually using FindFirstChild is because the model is added by the script during it's initial runtime, and without roblox would throw an error that the model doesn't exist yet.
Report Abuse
KarthonTulliusEnnius is not online. KarthonTulliusEnnius
Joined: 30 May 2010
Total Posts: 230
03 Jun 2015 10:15 AM
Okay, the script seems to work fine, now I just have to tune all of my scripts that update the players money, since we changed the storage system.
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