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

Set Datastore Data doesnt transfer from server to server?

Asked by 7 years ago
Edited 7 years ago

my data saves and loads inside the same server switching servers doesnt bring your saved stats from another

this problem occurs were it says

if data == "save" then
local event1 = Instance.new("RemoteEvent",game.ReplicatedStorage)--outfit1
event1.Name = "outfit1"
local event2 = Instance.new("RemoteEvent",game.ReplicatedStorage)
event2.Name = "outfit2"
local event3 = Instance.new("RemoteEvent",game.ReplicatedStorage)
event3.Name = "outfit3"


event1.OnServerEvent:connect(function(player,plr,data)
    print 'fired'
    local outfit1 = game:GetService("DataStoreService"):GetDataStore("Outfit1")
    local key = "player-"..plr.userId
    local plrstats = plr.Customization--Order in stats are saved {Hairs,Face,SkinColor,Shirt,Pants,Accessories1-5"}

    local vals = {
        plrstats.Hair,
        plrstats.Hair2,
        plrstats.Face,
        plrstats.Shirt,
        plrstats.Pants,
        plrstats.SkinColor,
        plrstats.Accessory1,
        plrstats.Accessory2,
        plrstats.Accessory3,
        plrstats.Accessory4,
        plrstats.Accessory5,
    }

    local valsToset = {}
    for k,v in pairs(vals) do
        valsToset[k] = v.Value
    end

    local saves = outfit1:GetAsync(key)

if data == "save" then
    outfit1:UpdateAsync(key,function(saves)
    local newvals = valsToset
    for i,v in pairs(newvals) do 
        saves[i] = newvals[i]
        return newvals
    end
    end)
end


if data == "load" then
        print 'loading'
    for i,v in pairs(vals) do      
        vals[i].Value = saves[i]
        print(saves[i])
    end
end


if data == "check" then
    print 'checking'
    for i,v in pairs(saves) do      
        print(saves[i])
    end
end



end)



1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Make sure your game is apart of a universe. The datastore will not transfer if it is not part of the universe.

You can read more about universes here

Once your universe is set up, you can transfer data from the datastore! :)

0
But its only a one place game xlaser23 60 — 7y
Ad

Answer this question