Alright, so Im trying to make a leaderboard script that saves the values from one place to another. However, it doesn’t work. For some reason though, the same script works perfectly fine on another game.
I have Access to studio API services turned on on both games.
Here is my script:
local DataStoreService = game:GetService(“DataStoreService”)
local DataStore = DataStoreService:GetDataStore(“MoneyStats”)
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new(“Folder”, Player)
Leaderstats.Name = “leaderstats”
local Currency = Instance.new(“IntValue”, Leaderstats)
Currency.Name = “PlaceID”
Currency.Value = 0
local Data = DataStore:GetAsync(Player.UserId)
if Data then
Currency.Value = Data
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, Player.leaderstats.PlaceID.Value)
end)
local DataStoreService = game:GetService(“DataStoreService”)
local DataStore = DataStoreService:GetDataStore(“PlaceIDStats”)
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new(“Folder”, Player)
Leaderstats.Name = “leaderstats”
local PlaceID= Instance.new(“IntValue”, Leaderstats)
PlaceID.Name = “PlaceID”
PlaceID.Value = 0
local PreviousePlaceID= Instance.new(“IntValue”, Leaderstats)
PreviousePlaceID.Name = “PreviousePlaceID”
PreviousePlaceID.Value = 0
local Data = DataStore:GetAsync(Player.UserId)
if Data then
PlaceID.Value = Data.PlaceID
PreviousePlaceID.Value = Data.PreviousePlaceID
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, {
[“PlaceID”] = Player.leaderstats.PlaceID.Value;
[“PreviousePlaceID”] = Player.leaderstats.PreviousePlaceID.Value;
})
end)
Anyone able to help me fix this?