Teleporting a word from one place to another

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

You could use Messaging service for that.

Im sorry, what? I can here for answers.

If you don’t know what’s messaging service then here is a tutorial

oh, no. Later im going to make it so that it sends a value, im just using a word for now. So thats not what im looking for.

Okay, Just saying it’s not allowed to give full codes.

Um, im sorry but can you show me where it says that? Ive came here multiple times with full codes and people were able to help me solve my problem

idk who you are but im just going to just discard all this

TeleportService can do that, if you’re teleporting a player, using TeleportData might solve your issue.

Official documentation on that can be found here.

Im teleporting data, thats what the topic is about

and also i just need my code debugged

TeleportData is an argument to :Teleport. You can retrieve it using TeleportService:GetLocalPlayerTeleportData, but there’s one for the server I forgot about.

Um, your repeating what i already did

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)

I didn’t know that TeleportData was for transferring.

yes, i realized im using a local script

You can just make a RemoteEvent system to fire whenever the teleport request should be sent. It already sends the player argument.

Can you help me make the entire script into a server script