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 8 years ago
local points = game:GetService("DataStoreService"):GetDataStore("Points")
local text = script.Parent.TextLabel
while wait() do
    text = "Coins : ".. points
end

And This

local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")

game.Players.PlayerAdded:connect(function(player)
    local key = "user_".. player.userId
    DataStore:UpdateAsync(key, function(oldValue)
        local newValue = oldValue or 0
        newValue = newValue + 50
    end)
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

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

2 answers

Log in to vote
3
Answered by 8 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 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

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

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

you need Text property, as the TextLabel is an object

also, the second one can be fixed too:

local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")

game.Players.PlayerAdded:connect(function(player)
    local key = "user_".. player.userId
    local data=DataStore[key]
    if not data then
        DataStore[key]=0
    end
    DataStore:UpdateAsync(key, function(oldValue)
        newValue = newValue + 50
    end)
end)

If it doesn't work, tell me ;p

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

Answer this question