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

DataStore not changing in other servers?

Asked by 8 years ago

I need some help with DataStaores. I need the value to be updated across all servers live, but I'm not sure why it's not working. The DataStore is being updated, but it's not being changed across all servers, so I'm assuming something's wrong with my UpdateAsync. I might be doing it completely wrong, though, because I just started working with DataStores today, so.. help please?

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

script.Parent.Number.Value.Value = DataStore:SetAsync("number",0)

script.Parent.Click.MouseButton1Down:connect(function()
    script.Parent.Number.Value.Value = (script.Parent.Number.Value.Value + 1)
    script.Parent.Number.Text = script.Parent.Number.Value.Value
    DataStore:UpdateAsync("number",function(oldValue)
        local newValue = oldValue or 0
        newValue = newValue + 1
        print("DataStore updated!")
        return newValue
    end)
end)




Answer this question