im making this teleport script, but i cant figure out why its not working
local UserInputService = game:GetService("UserInputService")
function teleport()
local t = game.Workspace:FindFirstChild("HumanoidRootPart")
if t == ("HumanoidRootPart") then
t.CFrame= t.Cframe + (t.CFrame.LookVector * Vector3.new(0,0,-5))
end
UserInputService.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E
then
print("teleport")
teleport()
end
end)
end
local UserInputService = game:GetService("UserInputService")
function teleport()
local t = game.Workspace:FindFirstChild("HumanoidRootPart")
if t and t.Name == ("HumanoidRootPart") then
t.CFrame= t.CFrame + (t.CFrame.LookVector * Vector3.new(0,0,-5))
end
end
UserInputService.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E then
print("teleport")
teleport()
end
end)
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
function teleport()
if Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
local t = Players.LocalPlayer.Character.HumanoidRootPart
t.CFrame= t.Cframe + (t.CFrame.LookVector * Vector3.new(0,0,-5))
end
end
UserInputService.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E then
print("teleport")
teleport()
end
end)