I have a leaderstats script which works in the game the script is located in, but when I try to access it in a different game (which is in the same universe) it doesn’t show up. How do I make it show up in the second game?
Main Game ( Overbooked)
Second Game (Game Place)
Game Hierarchy
Script:
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("Cash")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local currency = Instance.new("IntValue", folder)
currency.Name = "Cash"
local data
local success, errormessage = pcall(function()
data = ds:GetAsync(plr.UserId.."-cash")
end)
if success then
currency.Value = data
print("Successfully loaded Cash data")
else
print("Error loading Cash data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
ds:SetAsync(plr.UserId.."-cash", plr.leaderstats.Cash.Value)
end)
if success then
print("Successfully saved Cash data")
else
print("Error saving Cash data")
warn(errormessage)
end
game:BindToClose()
end)