Hello DevForum, I am using :PivotTo() to move my model based on where the player’s mouse position hit.
Now, I am doing that in a server script and I am requesting the mouse position of the player through a remote function, so it will be laggy.
This is the code :
task.spawn(function()
while move2.AdditionalTags["Cloud"] and move2.Charging do
local cloud: Model = move2.AdditionalTags["Cloud"]
local hrp_position = plr.Character.HumanoidRootPart.Position
local mousePos = tool.GetMousePositionIgnoreAll:InvokeClient(plr)
local difference = Vector3.new(mousePos.X - hrp_position.X, 0, mousePos.Z - hrp_position.Z)
local distance = difference.Magnitude
local range = math.clamp(distance, 0, 25)
local direction = difference.Unit
local newCloudPosition = hrp_position + direction * range
local vectorPos = Vector3.new(newCloudPosition.X, mousePos.Y, newCloudPosition.Z)
local CFrame_pos = CFrame.new(vectorPos)
cloud:PivotTo(CFrame_pos)
end
end)
If you have any idea, please let me know on how I can make the cloud move smooth, or atleast smoother.