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

Scripts don't work? + Screenshot

Asked by 9 years ago
1local points = game:GetService("DataStoreService"):GetDataStore("Points")
2local text = script.Parent.TextLabel
3while wait() do
4    text = "Coins : ".. points
5end

And This

1local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")
2 
3game.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)
9end)

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

0
Are you saving your DataStore for the next time he joins in? Azmidium 388 — 9y

2 answers

Log in to vote
3
Answered by 9 years ago

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.

0
This does't help me theawesome624 100 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

Easy, assuming the script is a LocalScript in a screen gui:

1local player=game:service'Players'.localPlayer
2repeat wait() until player
3local points = game:GetService("DataStoreService"):GetDataStore("Points")["user_"..player.userId]
4local text = script.Parent.TextLabel
5while wait() do
6    text.Text = "Coins : ".. points
7end

you need Text property, as the TextLabel is an object

also, the second one can be fixed too:

01local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")
02 
03game.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)
12end)

If it doesn't work, tell me ;p

0
Still shows 0 coins theawesome624 100 — 9y
0
Says DataStore can't be accessed from client, might have a fix. theawesome624 100 — 9y
0
Says ServerStorage is not a valid member of DataModel, might be another script theawesome624 100 — 9y
0
use RemoteEvents for getting the datastore Quil_Cyndaquil 26 — 9y

Answer this question