Little_Joes made a post on this already, but it hasn’t gotten any responses yet. I’m gonna post it again hoping we would get some responses
My friend, EcoCrashed, is making a story game, but there is one bug that occurs. There would be lag in one part, so we decided to make them teleport to a different place to get rid of it. Me, EcoCrashed, and Little_Joes have been stuck on this for a while now, and we have no clue why.
Here is the teleport script:
game.ReplicatedStorage.TeleportTime:FireAllClients()
for _, player in pairs(game.Players:GetPlayers()) do
local teleportData = {
health = player.Character.Humanoid.Health,
tools = {}
}
for _, tool in pairs(player.Backpack:GetChildren()) do
table.insert(teleportData.tools,tool.Name)
end
for _, tool in pairs(player.Character:GetChildren()) do
if tool:IsA('Tool') then
table.insert(teleportData.tools,tool.Name)
end
end
teleportData = game.HttpService:JSONEncode(teleportData)
teleportService:TeleportToPrivateServer(5844872161, code, {player}, teleportData)
end
Here is the local script from the destination place:
local player = game:GetService('Players').LocalPlayer
local teleportService = game:GetService('TeleportService')
local teleportData = teleportService:GetLocalPlayerTeleportData()
if teleportData then
teleportData = game.HttpService:JSONDecode(teleportData)
print('Teleport Data found!')
game.ReplicatedStorage.TeleportData:FireServer(teleportData)
else
print('No teleport data')
end
You might think the problem is will the JSONEncode and JSONDecode, but it’s not. We tested it without the JSON stuff, and we got an error saying "Unable to cast value to std::string"
.
Teleporting to the destination place works, but the script shows that we have teleport data that contains our health and items. For some reason, it shows that there is no teleport data when we arrive to the destination place. There is another script that gives us the tools and health, but that isn’t the problem. The problem is teleporting with the teleport data. Are we doing something wrong with the tables?