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

Is it possible to send data between place in Roblox?

Asked by 5 years ago
Edited 5 years ago

I'm struggling for searching for sharing my script to other place i saw some people said that data store is needed to pass it to other place but i already do it and also check the Enable Studio Access to API Services but still its not working so is anyone have an idea how other do that or where they get the information to do it?

local datastore = game:GetService("DataStoreService"):GetDataStore("experiment-datastore")
local Statsfolder = script.Stats

game.Players.PlayerAdded:Connect(function(newplayer)

    local key = "Player-ID:"..newplayer.UserId
    local GetSave = datastore:GetAsync(key)

    local newStatsfolder = Instance.new("Folder",newplayer)
    newStatsfolder.Name = "leaderstats"

    for i,Stats in pairs(Statsfolder:GetChildren())do
        local newStats = Instance.new(Stats.ClassName)
        newStats.Name = Stats.Name
        newStats.Value = Stats.Value
        newStats.Parent = newStatsfolder
    end

    if GetSave then
        for i,Stats in pairs(script.Stats:GetChildren())do
            newStatsfolder[Stats.Name].Value = GetSave[i]
            print(i,Stats.Name,Stats.Value)     
        end

    else

        local StatsToSave = {}

        for i,Stats in pairs(newStatsfolder:GetChildren())do
            table.insert(StatsToSave,Stats.Value)
            print(i,Stats.Name,Stats.Value)     
        end
        datastore:SetAsync(key, StatsToSave)
    end

    while wait(30) do

        local StatsToSave = {}

        for i,Stats in pairs(newStatsfolder:GetChildren())do
            table.insert(StatsToSave,Stats.Value)   
            print(i,Stats.Name,Stats.Value) 
        end
        datastore:SetAsync(key,StatsToSave)
    end

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

        local key = "Player-ID:"..oldplayer.UserId

        local StatsToSave = {}

        for i,Stats in pairs(newStatsfolder:GetChildren())do
            table.insert(StatsToSave,Stats.Value)
            print(i,Stats.Name,Stats.Value)     
        end
        datastore:SetAsync(key,StatsToSave)

    end)
end)

this is the script and its working but it can't be sent to my other place
script.Parent.MouseButton1Click:Connect(function()
    game:GetService("TeleportService"):Teleport(2805605031,game.Players.LocalPlayer)
end)

and here is my teleportservice script and i  dont know what to add
0
How are you trying to pass it? Are the places within the same game? DinozCreates 1070 — 5y
0
Yes it is RealPlays20 3 — 5y
0
Show the script and any errors DinozCreates 1070 — 5y
0
i cant comment it RealPlays20 3 — 5y
View all comments (18 more)
0
Just edit your question DinozCreates 1070 — 5y
0
i dont know im just new in here sorry RealPlays20 3 — 5y
0
Does the datastore not work at all? Or just not work in all of the places. The more information you give the less questions you need to answer. DinozCreates 1070 — 5y
0
data store is working but if i teleport to my other place same with the place with data store its not working only work in primary place RealPlays20 3 — 5y
0
Is your datastore script identical for both places or are they different? DinozCreates 1070 — 5y
0
i dont know but my datastore is only in my primary place i did not put it to other place RealPlays20 3 — 5y
0
Oh well thats the issue. You have to load the players data in from the seperate places, its not done automatically. DinozCreates 1070 — 5y
0
yes that's the issue but i dont know where to find information about doing data transfer to other place so i thought its not possible RealPlays20 3 — 5y
0
The datastore is shared between places under the same game, so you could essentially just trasnfer the same script over and it should be fine. DinozCreates 1070 — 5y
0
do i need to copy the datastore script to other place? is that what you mean? RealPlays20 3 — 5y
0
Thats right. If you dont tell the place to load/save the data it wont. DinozCreates 1070 — 5y
0
ok thanks i'll try it RealPlays20 3 — 5y
0
Yes It's Possible Only You Need To Do Is Simple Like If The Data Are Leaderboards Only Go To Game Explorer Places And press right click Then You Can Make A New Game On There So Do It Copy And Paste The Another Game And Put The Datastore In That Game, And It's Done. TrossCraft -13 — 5y
0
its not working they have different data but same script.i try some experiment and add points giver and if i touch that part i will get 100 points and then i try test it and i have 100 point in primary place and when i teleport to other place its still 0 so that means they have different data but its same script RealPlays20 3 — 5y
0
How are you giving the player points? With a local script? DinozCreates 1070 — 5y
0
he have all the same data check this the same datastore need to be for it works. TrossCraft -13 — 5y
0
no im giving player points using touched event in part RealPlays20 3 — 5y
0
You REALLY need to rethink the logic behind this. PlayerRemoving and your while-loop should not be inside the PlayerAdded. Review DataStores some more too. xPolarium 1388 — 5y

Answer this question