Teleport players gui

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make an admin gui which has a feature where you can teleport to players and you can teleport players to you.

  2. What is the issue? I have a local script inside of the gui which handles sending a message to the Main script (which is a server script) via a remote event. The remote event is not the problem and instead it is the part where it gets the input from the text box in the gui.

  3. What solutions have you tried so far? I have tried messing around with the local scripts code and the text box which has not worked.

Screenshot of explorer

Main script ( server script. relevant parts only)

--Variables--
player = script.Parent.Player.Value
TPToPlayer = game.ReplicatedStorage.RemoteEvents.TPToPlayer


--Teleport to player--
TPToPlayer.OnServerEvent:Connect(function(player,plr)
	if workspace:FindFirstChild(plr) then
		workspace[player].Head.CFrame = workspace[plr].Head.CFrame
		TeleportToPrint.Text = "Success!"
	else
		TeleportToPrint.Text = "Could not find "..plr
	end
end)

TPToPlayer (local script)

--Variables--
RE = game.ReplicatedStorage.RemoteEvents.TPToPlayer
B = script.Parent.Parent.TeleportToEnter
T = script.Parent.Text
plr = game.Players:FindFirstChild(T).Name


--Remote event--
B.MouseButton1Click:Connect(function()
	RE:FireServer(plr)
end)

Change workspace[player].Head.CFrame to workspace[player.Name].Head.CFrame or player.Character.Head.CFrame

Edit: Also, do as @rtvr56565 stated too.

I think you should update the T and plr values when you click the button, or else the player text can’t get updated

--Variables--
RE = game.ReplicatedStorage.RemoteEvents.TPToPlayer
B = script.Parent.Parent.TeleportToEnter


--Remote event--
B.MouseButton1Click:Connect(function()
    T = script.Parent.Text
    plr = game.Players:FindFirstChild(T).Name
	RE:FireServer(plr)
end)
3 Likes

thanks for helping me with this, I have spent the last hour trying to figure it out until I made this post lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.