#Is this secure and good?

1 messages · Page 1 of 1 (latest)

wet island
#

Ok, I'm a bit indecisive if this is a good idea. I'm planning to store all the player's data in a dictionary in a modulescript in serverscriptservice. (Only serverscripts can access it) This way I can easily recall it and i'm just wondering if it's safe/efficient.

wet island
#

finally someone

vagrant kindle
#

Efficiency I have no idea, but you're basically storing a table of information globally instead of in one script

wet island
vagrant kindle
#

Of course you can also make a module script have util functions too

wet island
#

what is the point of that

vagrant kindle
#

Instead of let's say 4 separate scripts having their own saving, loading, ect logic, you just have one DataStoreModule that does that for you, those scripts will just have to call those functions themselves

#

Another useful example:
You won't need to have a script that handles the player leaving and joining, that can also be handled in the module script

wet island
#

they just recall it from this dictionary

vagrant kindle
wet island
vagrant kindle
#

I'd personally separate the modules into categories

vagrant kindle
wet island
#

the datastore getasyncs the data

#

and puts it in this modulescript

#

and each script takes what they need

vagrant kindle
#

Example of my Forwards-And-Backwards-Inverse-Kinematics module.
The main module, works as a loader basically, it connect the smaller modules, which in my case are "Segment" and "Chain", making the different parts easy to modify.

wet island
#

its like 1 line of code to recall it

vagrant kindle
#

I am just telling you good practices, especially for someone with an s1

wet island
#

so like under a modulescript

#

theres more modulescripts

vagrant kindle
#

Pretty much yeah

wet island
#

this modulescript

vagrant kindle
#

It would let you edit different parts of your logic without cluter

wet island
#

is just for storing a massive dictionary

#

that was the plan atleast

vagrant kindle
#

Okay, gimmie a sec, I'll show you an example of how I would personally handle DataStoring in my games

wet island
#

clutter reminds me of clutterfunk

#

smh

#

I already have this system implemented

#

im just seeing if its actually as secure and efficient as I think

vagrant kindle
#

There isn't much of a security risk

#

Since modules aren't replicated across server-client

wet island
#

yay

#

yeah

minor nest
vagrant kindle
minor nest
#

Profile service is pretty good

vagrant kindle
#

Get out of here

minor nest
#

??

#

Why

#

What’s the problem

vagrant kindle
#

If you're gonna get spoon-fed other's people work, you'll never improve

#

I am trying to teach him here and you come and just say "Use someone else's work"

minor nest
#

Sorry but I don’t have the knowledge to make such a good data system but I also don’t want it to hold me back from game dev

vagrant kindle
#

It's fine, but not the current point of this convo

minor nest
#

I’m not telling him to use profile service

#

I just said that’s what profile service does

wet island
#

ive heard of profileserver but was too lazy to research it

minor nest
#

It’s very reliable

wet island
#

bc datastoreservice was already known to me

minor nest
#

From what I heard

minor nest
#

The main reason to use something like profile service is session locking

#

But I looks at profile service code and there’s so much other shit

#

Which is there for good reason most likely

wet island
#

is that like

minor nest
#

And idk how todo all that stuff

wet island
#

the spr library module

minor nest
#

So I just use the module

vagrant kindle
#

@wet island Also, here's what my approach would basically look like:
DataStore is the main module that holds the data and has utility methods of "getPlayerValue(plr, category, value)" for example or "getPlayerCategory(plr, category)"

wet island
#

why make a function

#

when you can recall it from a dictionary

minor nest
#

In a table

vagrant kindle
minor nest
#

If not then u can lose data

wet island
#

what is session locking

#

like bindatclose

#

or whatever its called

minor nest
#

No

vagrant kindle
#

Since it's easier to:

local data = module:GetPlayerData()
if not data then return end

rather than

local data = module[categoryName][valueName]
if not data then return end

it makes your code cleaner and what not

minor nest
#

If player leaves server and data is in middle of being saved but before data is done being saved player is already in another server so the previous data is loaded

vagrant kindle
wet island
#

I can see that

minor nest
#

I think session locking kicks the player if their data is in middle of being saved after they left on another server

#

That’s what it does for profile service at least

vagrant kindle
#

Some wait for the data to be saved before loading it, others kick the player

wet island
#

isn't there like

#

:UpdateAysnc

#

that does this

vagrant kindle
#

That's not what it's used for

#

And you can still have issues with it

wet island
#

self-explanatory?

minor nest
#

I never rly had to worry about data since I began using profile service a while ago so if u want to save urself a headache id suggest that but if u wanna be innovative and not be “spoon-fed” code feel free to make ur own stuff

vagrant kindle
vagrant kindle
#

Basically

wet island
#

finding a problem and finding a solution

#

is the fun part

vagrant kindle
#

Profiles module would handle each individual profile of a player.
Saving would well... handle saving. Such as making sure data is saved.
Loading would make sure the data from another server has saved before loading it

wet island
#

and a serverscript would handle the saving and loading?

vagrant kindle
#

No

#

They'll only get data of the players.

#

Or set it

#

Though you still would need 1 ServerScript to "Turn On" the module

wet island
#

ill implement the modulescript to be functions

vagrant kindle
#

For example:
The leaderboard script's playerAdded event could look like this:

local playerData = module:getPlayerCategory(player, "leaderboard") --in a get method, you could add a wait of sorts so that this script waits for the data to load.
if not playerData return end --Player doesn't have data.
--Do stuff
wet island
#

ah

#

isn't modulescripts used when a function is used more than once

#

getting/saving data is only like once

vagrant kindle
#

If you want clean scripts, then no, getting/saving data isn't done once

wet island
#

😨

vagrant kindle
#

Which is why you'd want a module script to do that

#

since a clean script only does what it needs to do

wet island
#

so

vagrant kindle
#

and having a script that you need to constantly update with new player data isn't a clean script

wet island
#

pro scripters have everything in modulescripts

#

and scripts just recall it

vagrant kindle
wet island
#

scary stuff

vagrant kindle
#

Modularity is very important in high-levels

wet island
#

even when a function

#

is used once

vagrant kindle
#

Since it's easier to look through 300-ish lines of code in a module script than 2k-ish lines of code in a normal script to debug

vagrant kindle
vagrant kindle
#

Since if you're making let's say an IK script, yes, everything will be a module, since IK isn't something that would usually be done for 1 script

wet island
#

the hell is ik

vagrant kindle
#

Inverse Kinematics

wet island
#

ah

vagrant kindle
#

Since let's say I made an AI with 7 states and I am having issue with only 1 of those states.

#

Would it be easier for me to look through hundreds of lines of code, jumping between the very top and the very bottom to find the issue or just look through the lines of code that only handle that one specifc state?

wet island
#

this is what im doing

vagrant kindle
#

and imo, you could separate them into a utility module

wet island
#

equipping/unequipping

#

adding an item

#

removing an item

#

and moving around items in the inventory

#

I wanted them to be together

vagrant kindle
#

Since code usually follows a structure of
Variables > Functions > Connections

#

And if you want them to be grouped together, you can just make them a module.
Though that would still need context if you should or not

wet island
#

I don't get the point of this being a module

knotty stag
#

Maybe use a table in a module that saves it to a profile store, so you when you need it the module auto updates it, I could be stupid but that’s my take

vagrant kindle
#

Grouping the code?

wet island
vagrant kindle
knotty stag
wet island
knotty stag
#

Save and upload, google, cry, discover you were stupid then fix and repeat

vagrant kindle
#

People prefer to be spoon-fed stuff rather than work for it.

knotty stag
#

Datastore workflow guys

knotty stag
#

Cuz I’m bad like that

vagrant kindle
#

@wet island Actually, I remember one of my first attempts at data-storing and I used several bad practices, I'll show you

vagrant kindle
#

Not minding the "LoadPasses" function, I've basically repeated the same code 3 times.

wet island
#

my initial idea was

vagrant kindle
#

Which I could of easily made into a module system like I shown an example before

wet island
#

the data is only getted once

#

and setted once

vagrant kindle
#

Setting once is questionable

wet island
#

well

#

pcall it

#

if it breaks do it like 3 more times

vagrant kindle
#

I prefer to have a auto-save every 2 minutes?

wet island
vagrant kindle
#

Yeah, exactly.

#

So it's not set only once

wet island
#

mb

#

ill show you my datastoreservice code

vagrant kindle
#

It's aight.

#

I've said as much as I can tbh.

wet island
#

ill try

#

i will replace the dictionary searching for functions

vagrant kindle
#

If you want, you can add me if you're 17 and up, otherwise just a simple dm when you have a question will suffice

vagrant kindle
#

And to remind you of the answer:
Yes, it is secure and most of the time it's good enough.

wet island
#

yay

vagrant kindle
#

But for cases like the default roblox leaderboard, you'd need the Leaderboard script to update the values in the leaderstats and the dictionary at the same time.

wet island
#

datastoreservice

wet island
#

I like things done all by me

#

auto-saving

vagrant kindle
wet island
vagrant kindle
#

Dude

wet island
#

?

vagrant kindle
#

what the fuck are you doing with coroutine.resume(coroutine.create)

wet island
#

I'm not that good with them

vagrant kindle
#

You can just use task.spawn()

#

Since I assume you're doing it so that it wouldn't block code that comes after it.

wet island
vagrant kindle
#

This sums it up well enough

wet island
#

I gtg

#

anyways thanks

#

i'll try to implement these

vagrant kindle
#

good luck gang

minor nest
#

Yall still here

wet island
#

we're done

minor nest
#

O

wet island
#

post closed