Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Scripts don't work? + Screenshot

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

1 comment

0

Are you saving your DataStore for the next time he joins in?

2 answers

✓ Accepted answer

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.

1 comment

0

This does't help me

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

4 comments

0

Still shows 0 coins

0

Says DataStore can't be accessed from client, might have a fix.

0

Says ServerStorage is not a valid member of DataModel, might be another script

0

use RemoteEvents for getting the datastore

This discussion is preserved as it was. New answers, comments, and votes are closed.