User:Anaminus/PlaceTransfer
From Legacy Roblox Wiki
Jump to navigationJump to search
Breakdown
Object -> Player Function -> Transfer Argument -> float PlaceId Argument -> string DataString Description -> If the current place is allowed in the target place's configuration, then exit from current place and load the target place. The string ''DataString'' gets passed along with the player. Function -> GetDataString Description -> Return the string that was passed with the player when transfered. If the player was not transerfered, return nil.
Place (ID: 12345): Configure: Allowable transfer places: 67890 54321 98765 +
Examples
Place teleporter
e = true function Touched(hit) if not e then return end e = false local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local data = "teleportername{" .. script.Parent.Name .. "}\n" if player:FindFirstChild("leaderstats") then for i,v in pairs(player.leaderstats:GetChildren()) do local str = "" if v.className == "IntValue" then str = str .. "stat" .. i .. "name{" .. v.Name .. "}\n" str = str .. "stat" .. i .. "value{" .. v.Value .. "}\n" end data = data .. str end end for i,v in pairs(player.Backpack:GetChildren()) do local str = "" if v.className == "Tool" or v.className == "HopperBin" then str = str .. "weapon" .. i .. "name{" .. v.Name .. "}\n" end data = data .. str end player:Transfer(67890,data) end e = true end script.Parent.Touched:connect(Touched)
Handle transfer
function PlayerEntered(player) local data = player:GetDataString() if data == nil then player:Remove() recent:Remove() end recent = nil local stats = {} local teleporter = string.gsub(data,"teleportername{(.-)}","%1") for id,value in str:gmatch("stat(%d+)name{(.-)}") do stats[(tonumber(id) or id)] = value end for id,value in str:gmatch("stat(%d+)value{(.-)}") do stats[stats[(tonumber(id) or id)]] = (tonumber(value) or value) stats[(tonumber(id) or id)] = nil end local board = Instance.new("IntValue") board.Name = "leaderstats" for i,v in pairs(stats) do local stat = Instance.new("IntValue") stat.Name = i stat.Value = v stat.Parent = board end while true do if player.Character ~= nil then break end wait() end local teleporter = workspace:FindFirstChild(teleporter) if teleporter ~= nil then player.Character.CFrame = CFrame.new(0,5,0) + teleporter.Position end end recent = nil game.Players.PlayerAdded:connect(PlayerEntered) game.NetworkServer.ChildAdded:connect(function(client) recent = client end)