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: Having a script on a player forever?

Previous Thread :: Next Thread 
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:25 PM
Hey guys, I have a quick question.

I have a global script (server script) in StarterPack and in this script i have a variable called
local sessionData

it is an array of items, such as Gold, and Level. However, when the player dies, it seems to reset the script. This is not good for me because i have to get the data from data store, but i dont want to get it again right after a death because it will spam too many requests. Basically i want a global script to keep attached to the player even after death.
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
18 Jan 2016 08:29 PM
server script in serverscriptservice

game.Players.PlayerAdded:connect(function(player)
-- leaderstats here
end)
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 08:32 PM
Put it in game.StarterPlayer.StarterPlayerScripts instead
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:33 PM
I tried to place it in StarterPlayerScripts, but server scripts wont run. I added a print statement on the 1st line and it would never show
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:37 PM
If I add the script in serverscriptservice, how would i know exactly which player the script holds the data to? Should i use an array of session datas and retrieve the session data from the array (which would require me to look up the index on the array and find it, which might not be most efficient). Or would my serverscriptservice have a script for each player, differentiated by their names? (e.g. xNitroSpeedxScript, [Player]Script)
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
18 Jan 2016 08:39 PM
@nitro
...the parameter player. You could make the leaderstats code in the same script as the datastore which is what I do and what I've seen others do
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 08:44 PM
My mistake I didn't realize it did not run server scripts


local statScripts = Instance.new("Folder", game:getService("ServerScriptService"))
statScripts.Name = "statScripts"

game.Players.PlayerAdded:connect(function(player)
local stats = script.statScript:clone()
stats.Parent = statScripts
stats.localPlayer.Value = player
stats.Disabled = false
end)



Put the stat script you want to not reset on death inside this script, disable it, and name it 'statScript' and put a object value in it named localPlayer.
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:46 PM
AH ok. Sorry about that, I've totally forgotten about Leaderstats. How about sensitive data that you don't want the player to see in the leaderboard?
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
18 Jan 2016 08:47 PM
Name it anything other than "leaderstats". I always store stats in a folder called statnumbers
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 08:47 PM
Use my example or one like it for sensitive data.
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 08:48 PM
'Name it anything other than "leaderstats". I always store stats in a folder called statnumbers'

You should store it in ServerScriptService instead
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:51 PM
Thank you both, I think I have my solution now. Anyhow, quick question: are server scripts in the workspace visible to the player? Can a hacker look inside a server script inside the workspace? Get data from it? If so, I think i should store most of my scripts in ServerScriptStorage
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 08:54 PM
Yes thats the purpose of serverScriptStorage

Anything in workspace is replicated.
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 08:56 PM
Ohhh ok, for some reason i thought server scripts in Workspace would be completely untouchable. Thanks, I will store my data in the ServerScriptService
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
18 Jan 2016 08:58 PM
goodie
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 09:02 PM
Notice serverScriptService appears empty to the client.

https://www.youtube.com/watch?v=bBqD8YgVxDs&feature=youtu.be
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
18 Jan 2016 09:24 PM
haha, thanks man. Appreciate the effort of creating the video!
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