generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Teleport when key is pressed script wont work

Previous Thread :: Next Thread 
KustyBurger is not online. KustyBurger
Joined: 14 Oct 2013
Total Posts: 47
04 Mar 2017 11:56 AM





function teleportPlayer(pos)

local player = game.Players.LocalPlayer
if player == nil or player.Character == nil then return end

local char = player.Character

char:MoveTo(pos)

end





plr = game.Players.LocalPlayer
mouse = plr:GetMouse()

mouse.KeyDown:connect(function(key)
if key == "b" then



teleportPlayer()

end
end)


-- its suppose to teleport you when you press the key b, but it won't work I get no errors in output
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
04 Mar 2017 11:57 AM
KeyDown is deprecated
Report Abuse
KustyBurger is not online. KustyBurger
Joined: 14 Oct 2013
Total Posts: 47
04 Mar 2017 11:58 AM
what?
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
04 Mar 2017 12:00 PM
KeyDown is not recommended to use in new projects.

Use UserInputService
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
04 Mar 2017 12:00 PM
to be used*
Report Abuse
KustyBurger is not online. KustyBurger
Joined: 14 Oct 2013
Total Posts: 47
04 Mar 2017 12:03 PM
im new to scripting i only know how to use the key function when it comes to button pressing scripts :(
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
04 Mar 2017 12:05 PM
teleportPlayer(mouse.Hit.p)
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
04 Mar 2017 12:06 PM
teleport(player, pos)
player.Character:MoveTo(pos)
end

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local key = "Q"

uis.InputBegan:connect(function(inputObject, event)
if event then return end
if inputObject.KeyCode == Enum.KeyCode[key] then
teleport(player, game.Workspace.Part.Position + Vector3.new(0, 3, 0))
end
end)
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
04 Mar 2017 12:06 PM
But you should get used to using UserInputService more.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image