Most efficient way of moving a part rapidly

Hello!

I just made a small script that allows the user to place and remove ropes and decided to add a little point that would indicate the current place location.

Tough, when I tested the script, I saw that by moving the mouse rapidly the script activity could up to 2% sometimes. To find the issue, I removed the part that moves the point and noticed that the activity was a lot lower ( max 0.1% ).

So i’m asking here, would there be a more efficient way of moving the point?

Thanks !

For this type of project I would suggest handling the visualization of the rope before you place it, solely on the client side, and just fire 1 remote event when the player places it (that could be what you’re already doing)

I don’t know about how efficient this method is, but it’ll be as smooth as possible:

local RS = game:GetService("RunService")
local Mouse = game.Players.LocalPlayer:GetMouse()

repeat
     RopeCurrentPosition.Position = Mouse.Hit.Position
     RS.RenderStepped:Wait()
until ropeplaced == true

This is pretty much what I’m doing. A little ball follows the position of the mouse on the client.

1 Like

I’ve managed to achieve what I wanted by using UIs that match the world location on screen and resize according to the distance to the camera.

Here is the code :

local ScreenPosition = Camera:WorldToViewportPoint(WorldPosition)

local SizeFactor = Scale / Position.Z -- Bigger scale = bigger frame
local Size = UDim2.fromOffset(1 * SizeFactor, 1 * SizeFactor)

Frame.Position = UDim2.fromOffset(Position.X - Size.X.Offset / 2, Position.Y - Size.Y.Offset / 2)
Frame.Size = Size