Hello, I am trying to make a script where you click a button and it will teleport you to a specific area.
This is the script:
local UIS = game:GetService(“UserInputService”)
local gui = script.Parent
local Back = gui.TeleportGUI.Exit
local TeleGui = gui.TeleportGUI
local Tele1 = gui.TeleportGUI.Tele1
gui.TeleportGUI.Visible = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
gui.TeleportGUI.Visible = true
end
end)
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Gui = script.Parent
local Back = Gui.TeleportGUI.Exit
local TeleGui = Gui.TeleportGUI
local Tele1 = Gui.TeleportGUI.Tele1
Gui.TeleportGUI.Visible = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
Gui.TeleportGUI.Visible = true
end
end)
Back.MouseButton1Click:Connect(function()
Gui.TeleportGUI.Visible = false
end)
Tele1.MouseButton1Click:Connect(function()
local Character = Player.Character
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
HumanoidRootPart.Position = Vector3.new(56.05, 0.5, -107.3) -- Getting the parts position to teleport to
end)
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Gui = script.Parent
local Back = Gui.TeleportGUI.Exit
local TeleGui = Gui.TeleportGUI
local Tele1 = Gui.TeleportGUI.Tele1
local TeleportPart = game.Workspace.TP1 -- Getting the part in the workspace
Gui.TeleportGUI.Visible = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
Gui.TeleportGUI.Visible = true
end
end)
Back.MouseButton1Click:Connect(function()
Gui.TeleportGUI.Visible = false
end)
Tele1.MouseButton1Click:Connect(function()
local Character = Player.Character
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
HumanoidRootPart.Position = TeleportPart.Position -- Teleporting the player to the part
end)