#How do I handle teleport data?
1 messages · Page 1 of 1 (latest)
for _,player in pairs(playerTable) do
allPlayerData[player.Name] = player:GetAttribute("CurrentCharacter") --this line
RemoteEvents.MiscRemoteEvents["TeleportEvent(used when teleporting a player from the client)"]:FireClient(player,"Teleporting in progress")
player.Character.HumanoidRootPart.Anchored = false
print(player.Name.." has been welded")
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Parent = Car
WeldConstraint.Part0 = Car
WeldConstraint.Part1 = player.Character:WaitForChild("HumanoidRootPart")
end
teleportOptions:SetTeleportData(allPlayerData) --this line
while true do
print("this ran")
task.wait(0.02)
if Car.CFrame.Z <= GoalPosition then break end
Car.CFrame = CFrame.new(Car.CFrame.Position - Vector3.new(0,0,1))
end
if not game:GetService("RunService"):IsStudio() then
TeleportService:TeleportToPrivateServer(placeID,PrivateReserveCode,playerTable,teleportOptions) --this line
Car.Position = CarOGPosition
Car.New_Project:Stop()
else
Car.Position = CarOGPosition
print("tpd all players")
Car.New_Project:Stop()
end
end
Script above, focus on comments lines (yes ik the ends are messed up, I copied a bit since the full one was too big)
Here is my server script when tping, under is my local script to get the data
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local data = TeleportService:GetLocalPlayerTeleportData()
print("Data should be under this")
print(data)
The local script above for data prints nil, how come? I have the correct attribute and everything but still no.
I have another test game I did it with.
Server script:
local TeleportService = game:GetService("TeleportService")
local placeId = 91845742016622
local teleportOptions = Instance.new("TeleportOptions")
local cd = false
local teleportData = {
["Character"] = 200
}
script.Parent.Touched:Connect(function(hit)
if cd then return end
cd = true
teleportOptions:SetTeleportData(teleportData)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:TeleportAsync(placeId,{player},teleportOptions)
end
end)
local script:
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("Local player arrived with this data:", teleportData)
This one prints the data tho for some reason
what's that
player:GetAttribute("CurrentCharacter")
That’s just for my game, I checked and it exists and the value is “None” so if it’s not set to anything it should print “None” not nil