i have a remote event that sends the player’s item name that they had from the other server when they join
--Client
task.wait(3)
local rs= game:GetService("ReplicatedStorage")
local ts = game:GetService("TeleportService")
local td = ts:GetLocalPlayerTeleportData()
if td ~= nil then
for i, v in pairs(td) do
print(v)
local obj = v
game.ReplicatedStorage.Remotes.getData:FireServer(obj)
end
end
--Server
game.ReplicatedStorage.Remotes.getData.OnServerEvent:Connect(function(plr, v)
print("recieved")
print(v)
if game.Workspace:FindFirstChild(v) then
local Item = workspace[v]:Clone()
Item.Parent = plr.Backpack
end
end)
on the client it prints “AlmondWater” if they had that in the other place before getting teleported to this place
on the server it prints “received” and “nil”
but they had almond water not nil
whats going on
im getting so tired of getting nil-related errors
The TeleportData is local to the client, so while the client can use it, the server has no access and from the server’s view it doesn’t exist which is why it is printing nil. Additionally, TeleportData is not secure and should not be used for sending sensitive data because exploiters can intercept and modify it. A more secure and server-sided solution is to send the data using MemoryStoreService.
MemoryStoreService allows you to save data for a set period of time (in this scenario, 120 seconds to allow enough time for teleports). This data will be available until it expires. So, whenever you teleport a player, send their data using MemoryStoreService and when they arrive at their destination (I would recommend using something like Players.PlayerAdded), you can retrieve their data since you will have their ID.
MemoryStoreService is server-sided which actually makes your life easier since you won’t need to use any RemoteEvents since it will already be on the server.
local ts = game:GetService("TeleportService")
local mss = game:GetService("MemoryStoreService")
local db = true
function touched(part)
if db then
local character = part.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local inv = player.Backpack:GetChildren()
mss:GetQueue(player.UserId, 30):AddAsync(inv, 30)
ts:Teleport(14580857434, player, inv)
end
task.wait(3)
db = true
end
end
script.Parent.Touched:Connect(touched)
i got this error
invalidrequest: unable to convert value to JSON. API: Queue.add, data structure: 1613443759
Looks like you can’t send Instances through MemoryStoreService because it gets encoded in JSON. If you have the items in the place you teleport the player to, you can send their names in a table then give them items based on the names in the table.