Why the teleport data doesn't work?
I created a place lets called it the place A, the start place. Place B is the other place within the game.
This is place A script when the player enters the game:
01 | local data = game:GetService( "DataStoreService" ) |
02 | local m = data:GetDataStore( "money" ) |
04 | game.Players.PlayerAdded:connect( function (p) |
06 | local stats = Instance.new( "Folder" , p) |
07 | stats.Name = "leaderstats" |
08 | local cash = Instance.new( "NumberValue" , stats) |
10 | cash.Value = m:GetAsync(p.UserId) or 100 |
11 | m:SetAsync(p.UserId, cash.Value) |
13 | cash.Changed:connect( function () |
14 | m:SetAsync(p.UserId, cash.Value) |
15 | print ( "saving:" ..p.Name.. " data" ) |
21 | game.Players.PlayerAdded:connect( function (p) |
23 | p:WaitForChild( "leaderstats" ) |
24 | m:SetAsync(p.UserId, p.leaderstats.cash.Value) |
Place A: Has a value and I want to teleport the data to place B.
Is it possible to teleport a data to place B that is in place A?
This is place B script:
1 | game.Players.PlayerAdded:connect( function (p) |
2 | local d = game:GetService( "TeleportService" ):GetLocalPlayerTeleportData() |
4 | print ( "Data is transfered!" ) |
Every time I joined place B with my teleport script:
01 | local TeleportService = game:GetService( "TeleportService" ) |
04 | function onTouched(hit) |
05 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
07 | TeleportService:Teleport(vb, player, player.leaderstats) |
12 | script.Parent.Touched:connect(onTouched) |
vb is the place B and I want to teleport the data to place B.
What am I doing wrong?