Advertisement
Guest User

Telekinesis Script (FE)

a guest
Sep 13th, 2024
11,833
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1.  
  2. local sandbox = function(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. local _Name = "Telekinesis V4"
  18. local uis = game:GetService("UserInputService")
  19. local _Ins, _CF_new, _VTR_new = Instance.new, CFrame.new, Vector3.new
  20. mas = _Ins("Model",game:GetService("Lighting"))
  21. Tool0 = _Ins("Tool")
  22. Part1 = _Ins("Part")
  23. Script2 = _Ins("Script")
  24. LocalScript3 = _Ins("LocalScript")
  25. Tool0.Name = _Name
  26. Tool0.Parent = mas
  27. Tool0.Grip = _CF_new(0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  28. Tool0.GripPos = _VTR_new(0, 0, 1)
  29. Part1.Name = "Handle"
  30. Part1.Parent = Tool0
  31. Part1.CFrame = _CF_new(-3.5, 5.30000019, -3.5, 1, 0, 0, 0, -1, 0, 0, 0, -1)
  32. Part1.Orientation = _VTR_new(0, 180, 180)
  33. Part1.Position = _VTR_new(-3.5, 5.300000190734863, -3.5)
  34. Part1.Rotation = _VTR_new(-180, 0, 0)
  35. Part1.Color = Color3.new(0.972549, 0.972549, 0.972549)
  36. Part1.Transparency = 1
  37. Part1.Size = _VTR_new(1, 1, 1)
  38. Part1.BottomSurface = Enum.SurfaceType.Smooth
  39. Part1.BrickColor = BrickColor.new("Institutional white")
  40. Part1.Locked = true
  41. Part1.TopSurface = Enum.SurfaceType.Smooth
  42. Part1.brickColor = BrickColor.new("Institutional white")
  43. Script2.Name = "LineConnect"
  44. Script2.Parent = Tool0
  45. local Sound = _Ins("Sound", game.Workspace)
  46. Sound.SoundId = "rbxassetid://1092093337"
  47. Sound:Play()
  48. table.insert(cors,sandbox(Script2,function()
  49. wait()
  50. local check = script.Part2
  51. local part1 = script.Part1.Value
  52. local part2 = script.Part2.Value
  53. local parent = script.Par.Value
  54. local color = script.Color
  55. local line = _Ins("Part")
  56. line.TopSurface = 0
  57. line.BottomSurface = 0
  58. line.Reflectance = .5
  59. line.Name = "Laser"
  60. line.Locked = true
  61. line.CanCollide = false
  62. line.Anchored = true
  63. line.formFactor = 0
  64. line.Size = _VTR_new(1,1,1)
  65. local mesh = _Ins("BlockMesh")
  66. mesh.Parent = line
  67. while true do
  68. if (check.Value==nil) then break end
  69. if (part1==nil or part2==nil or parent==nil) then break end
  70. if (part1.Parent==nil or part2.Parent==nil) then break end
  71. if (parent.Parent==nil) then break end
  72. local lv = _CF_new(part1.Position,part2.Position)
  73. local dist = (part1.Position-part2.Position).magnitude
  74. line.Parent = parent
  75. line.BrickColor = color.Value.BrickColor
  76. line.Reflectance = color.Value.Reflectance
  77. line.Transparency = color.Value.Transparency
  78. line.CFrame = _CF_new(part1.Position+lv.lookVector*dist/2)
  79. line.CFrame = _CF_new(line.Position,part2.Position)
  80. mesh.Scale = _VTR_new(.25,.25,dist)
  81. wait()
  82. end
  83. line:remove()
  84. script:remove()
  85. end))
  86. Script2.Disabled = true
  87. LocalScript3.Name = "MainScript"
  88. LocalScript3.Parent = Tool0
  89. table.insert(cors,sandbox(LocalScript3,function()
  90. wait()
  91. tool = script.Parent
  92. lineconnect = tool.LineConnect
  93. object = nil
  94. mousedown = false
  95. found = false
  96. BP = _Ins("BodyPosition")
  97. BP.maxForce = _VTR_new(math.huge*math.huge,math.huge*math.huge,math.huge*math.huge) --pwns everyone elses bodyposition
  98. BP.P = BP.P*3
  99. dist = nil
  100. point = _Ins("Part")
  101. point.Locked = true
  102. point.Anchored = true
  103. point.formFactor = 0
  104. point.Shape = 0
  105. point.BrickColor = BrickColor.Blue()
  106. point.Size = _VTR_new(1,1,1)
  107. point.CanCollide = false
  108. local mesh = _Ins("SpecialMesh")
  109. mesh.MeshType = "Sphere"
  110. mesh.Scale = _VTR_new(.7,.7,.7)
  111. mesh.Parent = point
  112. handle = tool.Handle
  113. front = tool.Handle
  114. color = tool.Handle
  115. objval = nil
  116. local hooked = false
  117. local hookBP = BP:clone()
  118. hookBP.maxForce = _VTR_new(30000,30000,30000)
  119.  
  120. function LineConnect(part1,part2,parent)
  121. local p1 = _Ins("ObjectValue")
  122. p1.Value = part1
  123. p1.Name = "Part1"
  124. local p2 = _Ins("ObjectValue")
  125. p2.Value = part2
  126. p2.Name = "Part2"
  127. local par = _Ins("ObjectValue")
  128. par.Value = parent
  129. par.Name = "Par"
  130. local col = _Ins("ObjectValue")
  131. col.Value = color
  132. col.Name = "Color"
  133. local s = lineconnect:clone()
  134. s.Disabled = false
  135. p1.Parent = s
  136. p2.Parent = s
  137. par.Parent = s
  138. col.Parent = s
  139. s.Parent = workspace
  140. if (part2==object) then
  141. objval = p2
  142. end
  143. end
  144.  
  145. function onButton1Down(mouse)
  146. if (mousedown==true) then return end
  147. mousedown = true
  148. coroutine.resume(coroutine.create(function()
  149. local p = point:clone()
  150. p.Parent = tool
  151. LineConnect(front,p,workspace)
  152. while (mousedown==true) do
  153. p.Parent = tool
  154. if (object==nil) then
  155. if (mouse.Target==nil) then
  156. local lv = _CF_new(front.Position,mouse.Hit.p)
  157. p.CFrame = _CF_new(front.Position+(lv.lookVector*1000))
  158. else
  159. p.CFrame = _CF_new(mouse.Hit.p)
  160. end
  161. else
  162. LineConnect(front,object,workspace)
  163. break
  164. end
  165. wait()
  166. end
  167. p:remove()
  168. end))
  169. while (mousedown==true) do
  170. if (mouse.Target~=nil) then
  171. local t = mouse.Target
  172. if (t.Anchored==false) then
  173. object = t
  174. dist = (object.Position-front.Position).magnitude
  175. break
  176. end
  177. end
  178. wait()
  179. end
  180. while (mousedown==true) do
  181. if (object.Parent==nil) then break end
  182. local lv = _CF_new(front.Position,mouse.Hit.p)
  183. BP.Parent = object
  184. BP.position = front.Position+lv.lookVector*dist
  185. wait()
  186. end
  187. BP:remove()
  188. object = nil
  189. objval.Value = nil
  190. end
  191.  
  192. function onKeyDown(key,mouse)
  193. local key = key:lower()
  194. local yesh = false
  195. if (key=="q") then
  196. if (dist>=5) then
  197. dist = dist-5
  198. end
  199. end
  200. if (key=="u") then
  201. if (dist ~=1) then
  202. BX = _Ins("BodyGyro")
  203. BX.MaxTorque = _VTR_new(math.huge,0,math.huge)
  204. BX.CFrame = BX.CFrame * CFrame.Angles(0, math.rad(45), 0)
  205. BX.D = 0
  206. BX.Parent = object
  207. --object.CFrame = CFrame.Angles(math.rad(90), 0,0) -- not used
  208. --object.Orientation = _VTR_new(50,0,0)
  209. --BX.Orientation = _VTR_new(23,0,0)
  210.  
  211. end
  212. end
  213. if (key=="p") then
  214. if (dist ~=1) then
  215. BX = _Ins("BodyVelocity")
  216. BX.maxForce = _VTR_new(0,math.huge,0)
  217. BX.velocity = _VTR_new(0,1,0)
  218. --BX.CFrame = BX.CFrame * CFrame.Angles(0, math.rad(45), 0)
  219. BX.Parent = object
  220.  
  221. end
  222. end
  223. if key == "l" then
  224. if (object==nil) then return end
  225. for _,v in pairs(object:children()) do
  226. if v.className == "BodyGyro" then
  227. return nil
  228. end
  229. end
  230. BG = _Ins("BodyGyro")
  231. BG.maxTorque = _VTR_new(math.huge,math.huge,math.huge)
  232. BG.cframe = _CF_new(object.CFrame.p)
  233. BG.Parent = object
  234. repeat wait() until(object.CFrame == _CF_new(object.CFrame.p))
  235. BG.Parent = nil
  236. if (object==nil) then return end
  237. for _,v in pairs(object:children()) do
  238. if v.className == "BodyGyro" then
  239. v.Parent = nil
  240. end
  241. end
  242. object.Velocity = _VTR_new(0,0,0)
  243. object.RotVelocity = _VTR_new(0,0,0)
  244. end
  245. if (key=="y") then
  246. if (dist ~=100) then
  247. dist = 100
  248. end
  249. end
  250. if (key=="j") then
  251. if (dist~=5000) then
  252. dist = 5000
  253. end
  254. end
  255. if (key=="e") then
  256. dist = dist+5
  257. end
  258. if (key=="x") then
  259. if dist ~= 15 then
  260. dist = 15
  261. end
  262. end
  263. end
  264.  
  265. function onEquipped(mouse)
  266. keymouse = mouse
  267. local char = tool.Parent
  268. human = char.Humanoid
  269. human.Changed:connect(function() if (human.Health==0) then mousedown = false BP:remove() point:remove() tool:remove() end end)
  270. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  271. mouse.KeyDown:connect(function(key) onKeyDown(key,mouse) end)
  272. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  273. if uis.TouchEnabled then
  274. uis.TouchEnded:Connect(function() mousedown = false end)
  275. else
  276. mouse.Button1Up:connect(function() mousedown = false end)
  277. end
  278. end
  279.  
  280. tool.Equipped:connect(onEquipped)
  281. tool.Unequipped:connect(function() mousedown = false end)
  282. end))
  283. for i,v in pairs(mas:GetChildren()) do
  284. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  285. pcall(function() v:MakeJoints() end)
  286. end
  287. mas:Destroy()
  288. for i,v in pairs(cors) do
  289. spawn(function()
  290. pcall(v)
  291. end)
  292. end
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement