Hello so i have two places and i want it so that when a player teleports to the place it also teleports the word “hi” and set the value of the other game to that. It wont work and im not catching any errors
LocalScript inside the button(1st Place):
local selectButton = script.Parent
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
local AbilityRemote = game.ReplicatedStorage.AbilityRemote
repeat wait() until script.Parent.Text ~= "Button"
selectButton.MouseButton1Click:Connect(function()
if selectButton.Text == "Play" then
local data = {}
data["Ability"] = "hi"
TeleportService:Teleport(8657574891, player, data)
end
end)
Local Script in starter gui(2nd Place):
local TeleportService = game:GetService("TeleportService")
local data = TeleportService:GetLocalPlayerTeleportData()
local player = game.Players.LocalPlayer
local Element1 = player.leaderstats:WaitForChild("Element1")
if data then
local Ability = data["Ability"]
Element1 = Ability
else
Element1 = "N/A"
end
TeleportData is an argument to :Teleport. You can retrieve it using TeleportService:GetLocalPlayerTeleportData, but there’s one for the server I forgot about.
I don’t know if that’s a good practice but this will work if the teleported place is connected to the main place.
Save the values you want to send to another place with DataStoreService. Make sure you’ve saved the values to a unique key, I recommend something that includes UserId.
Once the player is teleported to the game, load the data you’ve saved before teleporting with the same key and you’ll achieve what you wanted.
Very strange. For SQuiz, using TeleportData worked perfectly fine. The temporary update lobby also worked perfectly fine. I think the problem is that you’re using LocalScripts. I’m not sure why this would be the problem though.
I hate to admit this but the official documentation says so, because teleport data can be faked.
Change of plans for both of you replying to this post. Can you actually help me make this script into a server script, i have an idea.
local selectButton = script.Parent
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
local AbilityRemote = game.ReplicatedStorage.AbilityRemote
repeat wait() until script.Parent.Text ~= "Button"
selectButton.MouseButton1Click:Connect(function()
if selectButton.Text == "Play" then
local data = {}
data["Ability"] = "hi"
TeleportService:Teleport(8657574891, player, data)
end
end)