Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to build a Table to Handle all User data?

Asked by
58Renz 2
5 years ago

Hello Guys, Im very new in Roblox Scripting... i have some problems with the Lua Syntax...

if i do something like this in a ModuleScript in ReplicatedStorage

local dHandle = {}
dHandle .PlayerData = {}
return dHandle

and try to use it with a LocalScript it works, But in this Case, all Users on the Server uses the Same "Money" Cell of the Table? Right.?

local dHandle = require(game.ReplicatedStorage.ModuleScript)

dHandle.PlayerData["Money"] = 100
print(dHandle.PlayerData["Money"])

Now my Question:

How to build a table like this:

Table[UserID]["Money"]

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

When a player joins the game you want to add them to the table by giving them a key(this will only add a new key to the table, it will not affect any other items in the table).

PlayerData[Key] = {"Money" = 50}

to Change that users data you would...

PlayerData[Key]["Money"] = PlayerData[Key]["Money"] + 50

This adds 50 money to the player

Of course you are probably wanting more depth than this, here is a good resource when using a module. Should help you walk through the process.

https://developer.roblox.com/articles/Saving-Player-Data

Ad

Answer this question