Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local telekinesisObject = nil
- mouse.Button1Down:Connect(function()
- local target = mouse.Target
- if target then
- -- Check if the target is a valid object to move
- if target:IsA("Model") or target:IsA("Part") or target:IsA("Player") then
- telekinesisObject = target
- end
- end
- end)
- mouse.Button1Up:Connect(function()
- telekinesisObject = nil
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- if telekinesisObject then
- -- Change the position of the object to the cursor's position
- local playerHead = player.Character.Head
- local targetPos = mouse.Hit.p
- local direction = (targetPos - playerHead.Position).unit
- telekinesisObject.CFrame = CFrame.new(playerHead.Position + direction)
- end
- end)
- game:GetService("RunService").Stepped:Connect(function()
- if telekinesisObject then
- telekinesisObject.Velocity = Vector3.new(0, -50, 0)
- telekinesisObject = nil
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment