Meliodas0_0

Ctrl tp using TweenService

Feb 6th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. local speed = 100 -- set this lower to make it slower
  2. local bodyvelocityenabled = true -- set this to false if you are getting kicked
  3.  
  4. local Imput = game:GetService("UserInputService")
  5. local Plr = game.Players.LocalPlayer
  6. local Mouse = Plr:GetMouse()
  7.  
  8. function To(position)
  9. local Chr = Plr.Character
  10. if Chr ~= nil then
  11. local ts = game:GetService("TweenService")
  12. local char = game.Players.LocalPlayer.Character
  13. local hm = char.HumanoidRootPart
  14. local dist = (hm.Position - Mouse.Hit.p).magnitude
  15. local tweenspeed = dist/tonumber(speed)
  16. local ti = TweenInfo.new(tonumber(tweenspeed), Enum.EasingStyle.Linear)
  17. local tp = {CFrame = CFrame.new(position)}
  18. ts:Create(hm, ti, tp):Play()
  19. if bodyvelocityenabled == true then
  20. local bv = Instance.new("BodyVelocity")
  21. bv.Parent = hm
  22. bv.MaxForce = Vector3.new(100000,100000,100000)
  23. bv.Velocity = Vector3.new(0,0,0)
  24. wait(tonumber(tweenspeed))
  25. bv:Destroy()
  26. end
  27. end
  28. end
  29.  
  30. Imput.InputBegan:Connect(function(input)
  31. if input.UserInputType == Enum.UserInputType.MouseButton1 and Imput:IsKeyDown(Enum.KeyCode.LeftControl) then
  32. To(Mouse.Hit.p)
  33. end
  34. end)
Add Comment
Please, Sign In to add comment