Telekinesis Script

Hey! I’m Div. I was searching for a Telekinesis script so like for example, you hold on a part left click and you can move it with your mouse. But it’s not going back. Just to the left so like when you go with your mouse to the left or to the right < with the mouse.

I hope you can help my out by this problem!

Thank you.

2 Likes

you could use mouse.Hit to check what part it is and all its properties so you can maybe do it where whenever mouse is clicked it check if the part is unachored you can move it by changing the part position based on mouse.Hit.p

Kk. I understand but basiclly I shoud have to use only x and y to make it like how I want it. Right? But what is if I rotate me in a direction where I have to use y and z?

actually mouse.Hit.p gives a vector3 so you dont have to worry

1 Like

I actually made a couple before.

What you have to do is:

  • Make an attachment in the object.
    Make sure the object is all welded
  • When User clicks a button send that data to the server. The server then checks the distance to see if it is close enough to be lifted.
  • Server ads vector force with gravity multiplied by 110% of the mass. That gives the effect of lifting.

I didn’t do this but if you give a small random rotation to the object via angular velocity it might look event better.

you can just make a part appear at the front of your players camera and that would do i suppose

Hm. but I want to make it like it moves with my mouse but not in the back. Only left / right and up or down. Any way to make it like this?

Alright. Well it might be something like this

  1. Create attachment at the point you are holding create an attachment

  2. Fire a ray from the players camera to the mouse to make sure the objects distance

  3. Set the objects NetworkOwnerShip to the player.

  4. Add an attachment in terrain at the point your mouse it at too.

  5. Add a LineForce.

  6. Everytime your mouse moves fire a raycast with the distance you got from step 2. If it hits something update the attachment in the terrain to your mouse positiion or the Hit position of the raycast IF there is onw.

  7. Give the player some time then set the network ownership back to the server.

I-… I’ve never really worked with NetworkOwnerShip or raycast… Do you have maybe any tutorials? Oh and thank you for your time!

Don’t worry I am happy to help.

Raycasts are pretty easy once you get the hang of it.

You might want to look at these resources for it: WorldRoot | Roblox Creator Documentation and Raycasting | Roblox Creator Documentation

Basically you need to insert the Camera’s Position as the place where the raycast starts and the Mouse.Hit.Position - Camera.CFrame.Position as the direction

Network ownership is simply the way the server handles physics distribution between clients and server.

If you set the network ownership to player you can control objects that will replicate to the server via a localscript. The reason why we do this is because it is a lot more performant rather than sending a RemoteEvent everyframe from the client to the server which can really impact performance.

Usually network ownership is on the server to prevent exploiters from randomly moving objects around but since you WANT the player to move the object around NetworkOwnership is the way to do it.

I also managed to find the place I made with the spells. Ashaway Prototype - Roblox
You can use MMB and LMB to use the tools.

I might make a tutorial on Network Owneship soon actually.

1 Like

Oh okie dokie! That helped me a lot. Thank you! <3

do the same but with mouse.hit mouse.hit means mouse cframe mouse.hit.p means mouse position in a 3d world