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

[ CASE CLOSED? ]

Asked by 3 years ago
Edited 3 years ago

I have this datastore script but its not saving my data and I was wondering if its because im in studio?

local datastoreservice = game:GetService("DataStoreService")
local datastore = datastoreservice:GetDataStore("mydatastore")
game.Players.PlayerAdded:Connect(function(player)

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local Green = Instance.new("IntValue")
    Green.Name = "Green"
    Green.Parent = leaderstats
    Green.Value = datastore:GetAsync(player.UserId.."Green")

end)

game.Players.PlayerRemoving:Connect(function(player)

    datastore:SetAsync(player.UserId.."Green", player.leaderstats.Green.Value)

end)
0
try it in a game LuiOG 0 — 3y
0
Ok User#39520 0 — 3y
0
I think it worked XD User#39520 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Go to Studio>Settings>Security>Enable Studio Access to API services>On What that does is it lets you test datastores in studio. Also, I recommend making an answer if someone or yourself answers you question, and so if you accept it, both of you will get some reputation.

Ad

Answer this question