#How can I use Suphi's Datastore Module to transfer data to another place.

1 messages · Page 1 of 1 (latest)

grand arrow
#
local DataStoreModule = require(game.ServerStorage.SDM)

local template = {
    Firstname = "",
    Lastname = "",
    Age = 0,
    Cash = 0,
}

local function StateChanged(state, dataStore)
    while dataStore.State == false do
        if dataStore:Open(template) ~= "Success" then task.wait(6) end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    local dataStore = DataStoreModule.new("Stats", player.UserId)
    if dataStore.StateChanged:Connect(StateChanged) then
        StateChanged(dataStore.State, dataStore)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local dataStore = DataStoreModule.find("Stats", player.UserId)
    if dataStore ~= nil then dataStore:Destroy() end
end)

my template/data i want to transfer

grand arrow
#

nvm solved it^^

echo panther
#

nice

short vale
#

To transfer player data to another place

grand arrow
short vale
#

Ok thank you 🙏

short vale
#

@grand arrow

grand arrow
#

Place A - StartPlace script

local TeleportService = game:GetService("TeleportService")
local Teleport = game:GetService("ReplicatedStorage"):WaitForChild("Teleport")
local DataStoreModule = require(game.ServerStorage.SDM)


Teleport.OnServerEvent:Connect(function(player)
    if player == nil then return end
    local dataStore = DataStoreModule.find("Stats", player.UserId)
    if dataStore == nil then return end
    if dataStore.State ~= true then return end
    
    local transferData = { -- the data i want to transfer
        firstname = dataStore.Value.Firstname;
        lastname = dataStore.Value.Lastname;
        Age = dataStore.Value.Age;
        Cash = dataStore.Value.Cash;
        HasData = dataStore.Value.HasData;
        Bank = dataStore.Value.Bank;
    }
    TeleportService:Teleport(16803977589 -- (The place i want tp to), player, transferData)
end)

-- pretty self explanatory. make sure you have the basic template set up in both places
#

On Place B - which is the place you are teleporting too all you need is the template set up

#
local DataStoreModule = require(game.ServerStorage.SDM)

local template = {
    Firstname = "",
    Lastname = "",
    Age = 0,
    Cash = 0,
    Bank = 500
}

local function StateChanged(state, dataStore)
    while dataStore.State == false do
        if dataStore:Open(template) ~= "Success" then task.wait(6) end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    local dataStore = DataStoreModule.new("Stats", player.UserId)
    if dataStore.StateChanged:Connect(StateChanged) then
        StateChanged(dataStore.State, dataStore)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local dataStore = DataStoreModule.find("Stats", player.UserId)
    if dataStore ~= nil then dataStore:Destroy() end
end)
#

im bad at explaining stuff i hope you understand

short vale
#

👍