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

Why the teleport data doesn't work?

Asked by 7 years ago

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:

01local data = game:GetService("DataStoreService")
02local m = data:GetDataStore("money")
03 
04game.Players.PlayerAdded:connect(function(p)
05 
06    local stats = Instance.new("Folder", p)
07    stats.Name = "leaderstats"
08    local cash = Instance.new("NumberValue", stats)
09    cash.Name = "cash"
10    cash.Value = m:GetAsync(p.UserId) or 100
11    m:SetAsync(p.UserId, cash.Value)
12 
13    cash.Changed:connect(function()
14        m:SetAsync(p.UserId, cash.Value)
15        print("saving:"..p.Name.." data")
View all 26 lines...

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:

1game.Players.PlayerAdded:connect(function(p)
2    local d = game:GetService("TeleportService"):GetLocalPlayerTeleportData()
3    d.Parent = p
4    print("Data is transfered!")
5end)

Every time I joined place B with my teleport script:

01local TeleportService = game:GetService("TeleportService")
02local vb = 1532404369
03 
04function onTouched(hit)
05    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
06    if player then
07        TeleportService:Teleport(vb, player, player.leaderstats)   
08 
09    end
10end
11 
12script.Parent.Touched:connect(onTouched)

vb is the place B and I want to teleport the data to place B. What am I doing wrong?

Answer this question