hacimiks

Telekenesis V2

Apr 13th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.93 KB | None | 0 0
  1. -- Press a block to pick it (ignores anchored blocks) (there is a thing called network ownership so you cannot pick it but works on games sometimes like da hood)
  2. -- Long Press - Flings a block (power is customizable at line 19)
  3. -- Unequip  - Releases a block
  4. --Credits to the owner who made this script!!
  5. local function a(b, c)
  6.     local d = getfenv(c)
  7.     local e =
  8.         setmetatable(
  9.         {},
  10.         {__index = function(self, f)
  11.                 if f == "script" then
  12.                     return b
  13.                 else
  14.                     return d[f]
  15.                 end
  16.             end}
  17.     )
  18.     setfenv(c, e)
  19.     return c
  20. end
  21. local power = 500
  22. local usrinput = game:GetService("UserInputService")
  23. local g = {}
  24. local h = Instance.new("Model", game:GetService("Lighting"))
  25. local i = Instance.new("Tool")
  26. local j = Instance.new("Part")
  27. local k = Instance.new("Script")
  28. local l = Instance.new("LocalScript")
  29. local m = sethiddenproperty or set_hidden_property
  30. i.Name = "Telekinesis"
  31. i.Parent = h
  32. i.Grip = CFrame.new(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
  33. i.GripForward = Vector3.new(-0, -1, -0)
  34. i.GripRight = Vector3.new(0, 0, 1)
  35. i.GripUp = Vector3.new(1, 0, 0)
  36. j.Name = "Handle"
  37. j.Parent = i
  38. j.CFrame = CFrame.new(-17.2635937, 15.4915619, 46, 0, 1, 0, 1, 0, 0, 0, 0, -1)
  39. j.Orientation = Vector3.new(0, 180, 90)
  40. j.Position = Vector3.new(-17.2635937, 15.4915619, 46)
  41. j.Rotation = Vector3.new(-180, 0, -90)
  42. j.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  43. j.Transparency = 1
  44. j.Size = Vector3.new(1, 1.20000005, 1)
  45. j.BottomSurface = Enum.SurfaceType.Weld
  46. j.BrickColor = BrickColor.new("Really black")
  47. j.Material = Enum.Material.Metal
  48. j.TopSurface = Enum.SurfaceType.Smooth
  49. j.brickColor = BrickColor.new("Really black")
  50. k.Name = "LineConnect"
  51. k.Parent = i
  52. table.insert(
  53.     g,
  54.     a(
  55.         k,
  56.         function()
  57.             wait()
  58.             local n = script.Part2
  59.             local o = script.Part1.Value
  60.             local p = script.Part2.Value
  61.             local q = script.Par.Value
  62.             local color = script.Color
  63.             local r = Instance.new("Part")
  64.             r.TopSurface = 0
  65.             r.BottomSurface = 0
  66.             r.Reflectance = .5
  67.             r.Name = "Laser"
  68.             r.Locked = true
  69.             r.CanCollide = false
  70.             r.Anchored = true
  71.             r.formFactor = 0
  72.             r.Size = Vector3.new(1, 1, 1)
  73.             local s = Instance.new("BlockMesh")
  74.             s.Parent = r
  75.             while true do
  76.                 if n.Value == nil then
  77.                     break
  78.                 end
  79.                 if o == nil or p == nil or q == nil then
  80.                     break
  81.                 end
  82.                 if o.Parent == nil or p.Parent == nil then
  83.                     break
  84.                 end
  85.                 if q.Parent == nil then
  86.                     break
  87.                 end
  88.                 local t = CFrame.new(o.Position, p.Position)
  89.                 local dist = (o.Position - p.Position).magnitude
  90.                 r.Parent = q
  91.                 r.BrickColor = color.Value.BrickColor
  92.                 r.Reflectance = color.Value.Reflectance
  93.                 r.Transparency = color.Value.Transparency
  94.                 r.CFrame = CFrame.new(o.Position + t.lookVector * dist / 2)
  95.                 r.CFrame = CFrame.new(r.Position, p.Position)
  96.                 s.Scale = Vector3.new(.25, .25, dist)
  97.                 wait()
  98.             end
  99.             r:remove()
  100.             script:remove()
  101.         end
  102.     )
  103. )
  104. k.Disabled = true
  105. l.Name = "MainScript"
  106. l.Parent = i
  107. table.insert(
  108.     g,
  109.     a(
  110.         l,
  111.         function()
  112.             wait()
  113.             tool = script.Parent
  114.             lineconnect = tool.LineConnect
  115.             object = nil
  116.             mousedown = false
  117.             found = false
  118.             BP = Instance.new("BodyPosition")
  119.             BP.maxForce = Vector3.new(math.huge * math.huge, math.huge * math.huge, math.huge * math.huge)
  120.             BP.P = BP.P * 1.1
  121.             dist = nil
  122.             point = Instance.new("Part")
  123.             point.Locked = true
  124.             point.Anchored = true
  125.             point.formFactor = 0
  126.             point.Shape = 0
  127.             point.BrickColor = BrickColor.Black()
  128.             point.Size = Vector3.new(1, 1, 1)
  129.             point.CanCollide = false
  130.             local s = Instance.new("SpecialMesh")
  131.             s.MeshType = "Sphere"
  132.             s.Scale = Vector3.new(.7, .7, .7)
  133.             s.Parent = point
  134.             handle = tool.Handle
  135.             front = tool.Handle
  136.             color = tool.Handle
  137.             objval = nil
  138.             local u = false
  139.             local v = BP:clone()
  140.             v.maxForce = Vector3.new(30000, 30000, 30000)
  141.             function LineConnect(o, p, q)
  142.                 local w = Instance.new("ObjectValue")
  143.                 w.Value = o
  144.                 w.Name = "Part1"
  145.                 local x = Instance.new("ObjectValue")
  146.                 x.Value = p
  147.                 x.Name = "Part2"
  148.                 local y = Instance.new("ObjectValue")
  149.                 y.Value = q
  150.                 y.Name = "Par"
  151.                 local z = Instance.new("ObjectValue")
  152.                 z.Value = color
  153.                 z.Name = "Color"
  154.                 local A = lineconnect:clone()
  155.                 A.Disabled = false
  156.                 w.Parent = A
  157.                 x.Parent = A
  158.                 y.Parent = A
  159.                 z.Parent = A
  160.                 A.Parent = workspace
  161.                 if p == object then
  162.                     objval = x
  163.                 end
  164.             end
  165.             function onButton1Down(B)
  166.                 if mousedown == true then
  167.                     return
  168.                 end
  169.                 mousedown = true
  170.                 coroutine.resume(
  171.                     coroutine.create(
  172.                         function()
  173.                             local C = point:clone()
  174.                             C.Parent = tool
  175.                             LineConnect(front, C, workspace)
  176.                             while mousedown == true do
  177.                                 C.Parent = tool
  178.                                 if object == nil then
  179.                                     if B.Target == nil then
  180.                                         local t = CFrame.new(front.Position, B.Hit.p)
  181.                                         C.CFrame = CFrame.new(front.Position + t.lookVector * 1000)
  182.                                     else
  183.                                         C.CFrame = CFrame.new(B.Hit.p)
  184.                                     end
  185.                                 else
  186.                                     LineConnect(front, object, workspace)
  187.                                     break
  188.                                 end
  189.                                 wait()
  190.                             end
  191.                             C:remove()
  192.                         end
  193.                     )
  194.                 )
  195.                 while mousedown == true do
  196.                     if B.Target ~= nil then
  197.                         local D = B.Target
  198.                         if D.Anchored == false then
  199.                             object = D
  200.                             dist = (object.Position - front.Position).magnitude
  201.                             break
  202.                         end
  203.                     end
  204.                     wait()
  205.                 end
  206.                 while mousedown == true do
  207.                     if object.Parent == nil then
  208.                         break
  209.                     end
  210.                     local t = CFrame.new(front.Position, B.Hit.p)
  211.                     BP.Parent = object
  212.                     BP.position = front.Position + t.lookVector * dist
  213.                     wait()
  214.                 end
  215.                 BP:remove()
  216.                 object = nil
  217.                 objval.Value = nil
  218.             end
  219.             function onKeyDown(E, B)
  220.                 local E = E:lower()
  221.                 local F = false
  222.                 if E == "q" then
  223.                     if dist >= 5 then
  224.                         dist = dist - 10
  225.                     end
  226.                 end
  227.                 if E == "r" then
  228.                     if object == nil then
  229.                         return
  230.                     end
  231.                     for G, H in pairs(object:children()) do
  232.                         if H.className == "BodyGyro" then
  233.                             return nil
  234.                         end
  235.                     end
  236.                     BG = Instance.new("BodyGyro")
  237.                     BG.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  238.                     BG.cframe = CFrame.new(object.CFrame.p)
  239.                     BG.Parent = object
  240.                     repeat
  241.                         wait()
  242.                     until object.CFrame == CFrame.new(object.CFrame.p)
  243.                     BG.Parent = nil
  244.                     if object == nil then
  245.                         return
  246.                     end
  247.                     for G, H in pairs(object:children()) do
  248.                         if H.className == "BodyGyro" then
  249.                             H.Parent = nil
  250.                         end
  251.                     end
  252.                     object.Velocity = Vector3.new(0, 0, 0)
  253.                     object.RotVelocity = Vector3.new(0, 0, 0)
  254.                     object.Orientation = Vector3.new(0, 0, 0)
  255.                 end
  256.                 if E == "e" then
  257.                     dist = dist + 10
  258.                 end
  259.                 if E == "t" then
  260.                     if dist ~= 10 then
  261.                         dist = 10
  262.                     end
  263.                 end
  264.                 if E == "y" then
  265.                     if dist ~= 200 then
  266.                         dist = 200
  267.                     end
  268.                 end
  269.                 if E == "=" then
  270.                     BP.P = BP.P * 1.5
  271.                 end
  272.                 if E == "-" then
  273.                     BP.P = BP.P * 0.5
  274.                 end
  275.             end
  276.             function onEquipped(B)
  277.                 touched = false
  278.                 uneq = false
  279.                 keymouse = B
  280.                 local I = tool.Parent
  281.                 human = I.Humanoid
  282.                 human.Changed:connect(
  283.                     function()
  284.                         if human.Health == 0 then
  285.                             mousedown = false
  286.                             uneq = true
  287.                             touched = false
  288.                             BP:remove()
  289.                             point:remove()
  290.                             tool:remove()
  291.                         end
  292.                     end
  293.                 )
  294.                 usrinput.TouchTapInWorld:connect(
  295.                     function()
  296.                         if uneq == false then
  297.                         if touched == false then
  298.                         onButton1Down(B)
  299.                         touched = true
  300.                         elseif touched == true then
  301.                         touched = false
  302.                         end
  303.                         end
  304.                     end
  305.                 )
  306.                 usrinput.TouchLongPress:connect(function()
  307.                     if uneq == false then
  308.                         if dist ~= power then
  309.                             dist = power
  310.                         end
  311.                     end
  312.                 end)
  313.                 B.KeyDown:connect(
  314.                     function(E)
  315.                         onKeyDown(E, B)
  316.                     end
  317.                 )
  318.                 B.Icon = "rbxasset://textures\\GunCursor.png"
  319.             end
  320.             tool.Equipped:connect(onEquipped)
  321.             tool.Unequipped:connect(function() uneq = true touched = false mousedown = false end)
  322.         end
  323.     )
  324. )
  325. for J, H in pairs(h:GetChildren()) do
  326.     H.Parent = game:GetService("Players").LocalPlayer.Backpack
  327.     pcall(
  328.         function()
  329.             H:MakeJoints()
  330.         end
  331.     )
  332. end
  333. h:Destroy()
  334. for J, H in pairs(g) do
  335.     spawn(
  336.         function()
  337.             pcall(H)
  338.         end
  339.     )
  340. end
Add Comment
Please, Sign In to add comment