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

my datastore works fine, but when in another game does not work. how can i fix this?

Asked by 1 year ago

I have a datastore that works perfectly fine in one game, but when i put it into another, it does not work. i have literally copy and pasted the same thing into each game, and both games have API services turned on. the code is below.

local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("StarterCarUpgrades")

game.Players.PlayerAdded:Connect(function(Player) local clone = game.ReplicatedStorage.PlayerData:Clone() clone.StartercarUpgradeValue.Value = DataStore:GetAsync(Player.UserId) or 0 clone.Name = "PlayerData" clone.Parent = Player end)

game.Players.PlayerRemoving:Connect(function(Player) DataStore:SetAsync(Player.UserId, Player:WaitForChild("PlayerData").StartercarUpgradeValue.Value) end)

0
lol bro really tried to give himself currency that's not how it works lol Cooldoodle2019 4 — 1y
0
what did i do wrong? also how does this involve currency? kingmaster1033r 0 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

It's because each game has their own data saved. For example, you have a pet saved in Adopt Me. Would you expect your data would also show up in Murder Mystery 2? No! Just because you used the same DataStore name in a different game, doesn't mean it would have the same data from the other game.

If you try to transfer a DataStore script to an another game, it will just start a new copy of the DataStore from the previous game except it is reset back to no data saved.

There is no fix to this, except that you can use Badges to detect when a player owns something in the game. You can use that when you try to share your data to another game (probably your other game) like what The Mimic will do to their new game Yokai.

But you can only use Badges if you want to check if the player has earned an item or completed a quest, not for checking numbers and leaderstats.

0
I do not want the same datastore value saved into my other game, i just want it to restart the datastore, but still work. for this it doesnt reset my data, it just doesnt work. kingmaster1033r 0 — 1y
0
Maybe you forgit to add the PlayerData in ReplicatedStorage T3_MasterGamer 2189 — 1y
0
no, I just tried publishing the same game under a baseplate and it works there, just not for the game I want it to. I really don’t understand what I could be doing wrong. Is there a separate api service I have to enable other than just going to game settings and enabling it? kingmaster1033r 0 — 1y
0
I have API services on in both games. kingmaster1033r 0 — 1y
View all comments (2 more)
0
Try checking the output T3_MasterGamer 2189 — 1y
0
i just checked, nothing shows up kingmaster1033r 0 — 1y
Ad

Answer this question