Im trying to transfer a single datastore through a place but it doesnt work and i dont know how to make it work. My main places datastore script has this code and id like it to transfer between the places:
local dataStoreService = game:GetService("DataStoreService")
local myDataStore = dataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Nights = Instance.new("IntValue", leaderstats)
Nights.Name = "Nights"
Nights.Value = 0
Nights.Parent = leaderstats
local playerUserId = "Player_"..player.UserId
-- load data
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if success then
-- set data
Nights.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local data = player.leaderstats.Nights.Value
local success, errormessage = pcall(function()
myDataStore:SetAsync(playerUserId, data)
end)
if success then
print("Data successfully saved")
else
print("Error happened")
warn(errormessage)
end
end)
To teleport to that place i have this script:
local TPS = game:GetService("TeleportService")
script.Parent.MouseButton1Click:Connect(function(player)
local datastore = game.Players.LocalPlayer:WaitForChild("leaderstats").Nights
local player = game.Players.LocalPlayer
script.Parent.Parent.pleasewait.Visible = true
TPS:GetTeleportSetting(datastore)
TPS:Teleport(5616570036, player)
end)
And the script inside that place i want to teleport to gives me an error "WaitForChild is not a valid member of RBXScriptSignal, here is the code:
local leaderstats = game.Players.PlayerAdded:WaitForChild("leaderstats")
local nights = leaderstats.Nights
script.Parent.ClickDetector.MouseClick:Connect(function()
nights.Value = nights.Value + 1
end)
To clarify: Im trying to make it so a datastore script is accessible through multiplie places, and when i change the value of a leaderstat stat inside the new place it saves into the datastore and is accessible in the starting place.

2 comments
You can use a external webserver and database to do that, datastores are only shared if both places are on the same universe
You don't need an external database to keep data among places in a game. It's already a built-in feature that datastores are for entire games and not single places within the game.