Categories > Coding > Lua >

How to tp to a place get a item and tp back

Posts: 17

Threads: 10

Joined: Sep, 2022

Reputation: 0

Posted

How do i make a script that tp a player to a place and presses a key for example e or f and then tp back to where the player was orginally

 

If its confusing to understand then I will explain with an example

 

Im on a certain place and need to tp to a volcano where a weapon is and press hold a certain key (like f,e) to obtain the weapon and tp back to that certain place

  • 0

Posts: 1430

Threads: 71

Joined: May, 2022

Reputation: 20

Replied

store the cframe of the players head as a variable, tp somewhere and tp back to the head cframe variable after a few seconds

  • 0

i use arch btw

jex

yes

Posts: 1985

Threads: 128

Joined: Nov, 2019

Reputation: 13

Replied

local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("HumanoidRootPart",math.huge)
local position = hum.CFrame

local mouse = plr:GetMouse()

tp = mouse.KeyDown:Connect(function(key)
	if key == "j" then -- save your position
	position = hum.CFrame

	elseif key == "k" then -- go to your old position (change the keys if u want)
		hum.CFrame = position
		
	elseif key == "l" then -- to disconnect the function
		tp:Disconnect()
	end
end)

 

  • 0

yes

Posts: 1

Threads: 0

Joined: Dec, 2022

Reputation: 0

Replied

Nivito Nivito Nivito

  • 0

家の中で最も重要な部屋の一つは、キッチンです。 家族が一緒に料理して食べる場所、友人が一緒になって話をして笑う場所、そして思い出が作られる場所です。

キッチン 水 栓 銅

WetWipes

Professional Idiot

vip

Posts: 146

Threads: 32

Joined: Sep, 2020

Reputation: 14

Replied

Hey just quickly made this, is this what you was looking for?

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = Where you want to teleport back to -- CFrame of where you want to teleport back to
wait(1)
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = Volcano Place -- Set the CFrame of wherever the volcano is
wait()
keypress(0x46) -- This will click F
wait(2)
keyrelease(0x46) --This will release F
wait()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = Where you want to teleport back to -- CFrame of where you want to teleport back to
  • 0

Open to help anyone with anything, DM me on discord :)

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )