Instead of just making the player go really fast, I want to actually teleport a player based on their camera's lookVector. Maybe like 50 studs or so. All my code so far is in a local script inside of StarterGui. How would make this change? Any help is appreciated!
--Moving the Humanoid
--Double Tap
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled and clicked then
return
end
if key == "w" and _G.Energy >= 25 then
enabled = false
local function onTap()
if tick() - lastTapTime < 0.2 then
print("double Click!")
clicked = true
--What happends when the user double taps
player.Character.UpperTorso.Velocity = cam.CFrame.lookVector * Vector3.new(1,0,1) * 400 -- This is the part I want to change.
Trail.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.Head)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.HumanoidRootPart)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
wait(0.3)
Trail:Remove()
-- _G.Energy = _G.Energy - 25
wait(0.5)
end
end
onTap()
lastTapTime = tick()
wait(0.5)
enabled = true
clicked = false
end
end)
--[[--[[Double Jump
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled and clicked then
return
end
if key == " " and _G.Energy >= 12.5 then
enabled = false
local function onTap()
if tick() - lastTapTime < 0.2 then
print("double Click!")
clicked = true
--What happends when the user double taps
player.Character.UpperTorso.Velocity = Vector3.new(0, 100, 0)
Trail.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.Head)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.HumanoidRootPart)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
wait(0.3)
Trail:Remove()
_G.Energy = _G.Energy - 12.5
wait(1)
end
end
onTap()
lastTapTime = tick()
wait(0.5)
enabled = true
clicked = false
end
end)
--Repleneshing Energy
for i = 1, math.huge do
wait(0.1)
print(_G.Energy)
if _G.Energy < 100 then
_G.Energy = _G.Energy + 12.5
print(_G.Energy)
wait(2)
end
end
]]--]]

1 comment
I edited my answer hope it helps a little