Mryeetmemes

Telekinesis - Put in ScreenGui and its a localscript

Apr 21st, 2023
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3. local telekinesisObject = nil
  4.  
  5. mouse.Button1Down:Connect(function()
  6.     local target = mouse.Target
  7.     if target then
  8.         -- Check if the target is a valid object to move
  9.         if target:IsA("Model") or target:IsA("Part") or target:IsA("Player") then
  10.             telekinesisObject = target
  11.         end
  12.     end
  13. end)
  14.  
  15. mouse.Button1Up:Connect(function()
  16.     telekinesisObject = nil
  17. end)
  18.  
  19. game:GetService("RunService").RenderStepped:Connect(function()
  20.     if telekinesisObject then
  21.         -- Change the position of the object to the cursor's position
  22.         local playerHead = player.Character.Head
  23.         local targetPos = mouse.Hit.p
  24.         local direction = (targetPos - playerHead.Position).unit
  25.         telekinesisObject.CFrame = CFrame.new(playerHead.Position + direction)
  26.     end
  27. end)
  28.  
  29. game:GetService("RunService").Stepped:Connect(function()
  30.     if telekinesisObject then
  31.         telekinesisObject.Velocity = Vector3.new(0, -50, 0)
  32.         telekinesisObject = nil
  33.     end
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment