so ive allready read and tried this http://wiki.roblox.com/index.php?title=Teleportation it dind't work ..
but what i try to do is if you press X u get teleported so
if script.Parent.TP.Enabled == true then function Pressx(key) if(key == "x") then --game.Workspace.Player.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-2.7, -151.9, -580.5)) dind't work end end end
You tried to index "game.Workspace.Player" but likely "Player" is not a player in your game. Look at the output.
The simplest way to teleport is by cframing the torso. If you want to do it on 'X' then here is how.
game:GetService('UserInputService').InputBegan:connect(function(input,gpe) if (not gpe) and input.KeyCode == Enum.KeyCode.X then game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(Vector3.new(-2.7, -151.9, -580.5)) end end)
Like cabbler said, the problem likely is you tried to index 'Player' as though it were an actual Model/Character inside the workspace. To add upon what he said, it's better to use HumanoidRootPart to ensure compatibility with R15. Here's an updated version of your code:
game:GetService("UserInputService").InputBegan:connect(function(input, guiStatus) if not guiStatus and input.KeyCode == Enum.KeyCode.X then game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-2.7, -151.9, -580.5)) end end)
if script.Parent.TP.Enabled == true then function Pressx(key) if(key == "x") then game.Players.LocalPlayer.Character.Torso.CFrame = Vector3.new(0, 0, 0) end end end