Data loss during teleportation between two places from same experience [SOLVED]

I’m trying to save data between two different places from my same experience game. Basically there’s an arena consisting of players that will battle against each other and I want to make sure that when a placer wins a tournament he gets increased his values by 1 but also when the rig is teleported back to the gym his number of wins remains the same as it was after it increased to new value within the arena

I tried using GetData and even use datasavings and sadly didn’t worked pretty well I though game:BindToClose() would work also on teleportation but sadly I was wrong

I can’t understand what your problem is

If I understand right, your data isn’t saving when player is teleported, try to force save player data if he won?

That’s indeed right I just waked up from my bed

Power and Kill seems to work pretty well unlike wins when I go back in the game kill and power stay the same but my wins aren’t updating

I SOLVED MY PROBLEM AGAIN I KNEW THE ISSUE

Basically the thing is the data that was changed in the main place of the game which is the gym will be saved since the game recognise the main place experience however if you change the value within another place of the same experience which is not the primary place then the value won’t be saved on the main place the gym because it’s like it never changed in the first place since it didn’t happened on the gym but on the arena therefore to solve this problem we need to make sure to teleport the win data by using these lines of code to then call it back on the main experience place

Arena place which is the secondary place experience

for _, player in game.Players:GetPlayers() do
				
				local teleportOptions = Instance.new("TeleportOptions")
				--print(plr,fab,bel,bop,pow,jl)
				local teleportData = {
					placeId = game.PlaceId,
					wins = player.leaderstats.Wins.Value
				}
				teleportOptions:SetTeleportData(teleportData)
				teleportService:TeleportAsync(15541201381, {player}, teleportOptions)
			end	

Gym place which is the primary place experience

if player:GetJoinData().TeleportData then
    print("NUMBRE OF WINS PLAYERS IS : " .. player:GetJoinData().TeleportData.wins)
    player:WaitForChild("leaderstats").Wins.Value = player:GetJoinData().TeleportData.wins
else 
    player:WaitForChild("leaderstats").Wins.Value = playerClass.wins
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.