Categories > Coding > Lua >
How to tp to a place get a item and tp back
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
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
Cancel
Post
i use arch btw
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)
Cancel
Post
yes
Replied
Nivito Nivito Nivito
Cancel
Post
家ã®ä¸ã§æœ€ã‚‚é‡è¦ãªéƒ¨å±‹ã®ä¸€ã¤ã¯ã€ã‚ッãƒãƒ³ã§ã™ã€‚ 家æ—ãŒä¸€ç·’ã«æ–™ç†ã—ã¦é£Ÿã¹ã‚‹å ´æ‰€ã€å‹äººãŒä¸€ç·’ã«ãªã£ã¦è©±ã‚’ã—ã¦ç¬‘ã†å ´æ‰€ã€ãã—ã¦æ€ã„出ãŒä½œã‚‰ã‚Œã‚‹å ´æ‰€ã§ã™ã€‚
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
Cancel
Post
Open to help anyone with anything, DM me on discord :)
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post