1 | local points = game:GetService( "DataStoreService" ):GetDataStore( "Points" ) |
2 | local text = script.Parent.TextLabel |
3 | while wait() do |
4 | text = "Coins : " .. points |
5 | end |
And This
1 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "Points" ) |
2 |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | local key = "user_" .. player.userId |
5 | DataStore:UpdateAsync(key, function (oldValue) |
6 | local newValue = oldValue or 0 |
7 | newValue = newValue + 50 |
8 | end ) |
9 | end ) |
Do not work. How do I make these work? They should work, but this screen shot here shows 0 Coins (Yes I know, I'm not in game, but i tested it and they still do not work): http://prntscr.com/8mdigh
Well first off what are you adding to? Because the second script has no purpose other than changing in script variables.
The first script you need the value of the Points in the data store, hope this helps. I haven't answered in full, sorry. But anyway hope it helps.
Easy, assuming the script is a LocalScript in a screen gui:
1 | local player = game:service 'Players' .localPlayer |
2 | repeat wait() until player |
3 | local points = game:GetService( "DataStoreService" ):GetDataStore( "Points" ) [ "user_" ..player.userId ] |
4 | local text = script.Parent.TextLabel |
5 | while wait() do |
6 | text.Text = "Coins : " .. points |
7 | end |
you need Text property, as the TextLabel is an object
also, the second one can be fixed too:
01 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "Points" ) |
02 |
03 | game.Players.PlayerAdded:connect( function (player) |
04 | local key = "user_" .. player.userId |
05 | local data = DataStore [ key ] |
06 | if not data then |
07 | DataStore [ key ] = 0 |
08 | end |
09 | DataStore:UpdateAsync(key, function (oldValue) |
10 | newValue = newValue + 50 |
11 | end ) |
12 | end ) |
If it doesn't work, tell me ;p