Currently, I am using this really inefficient and laggy method.
--Script
script.Parent.Remotes.UpdatePos.OnServerInvoke = function(player, Model, pos1, pos2)
Model:SetPrimaryPartCFrame(CFrame.new(pos1, pos2))
end
--
--LocalScript
Functions = require(script:WaitForChild("Functions"))
RbxUtility = LoadLibrary("RbxUtility")
local RunService = game:GetService("RunService")
local Character
local Player
local PlayerMouse
local Tool = script.Parent
Players = game:GetService("Players")
Remotes = Tool:WaitForChild("Remotes")
ClientControl = Remotes:WaitForChild("ClientControl")
local Handle = script.Parent:WaitForChild("Firer").Value
script.Parent.Equipped:connect(function()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
PlayerMouse = Player:GetMouse()
local PreviousMouseHitP
RunService.RenderStepped:connect(function()
local magnitude = (Character.Torso.Position - PlayerMouse.Hit.p).magnitude
if magnitude > 10 then
if PlayerMouse.Hit.p == PreviousMouseHitP then
else
Remotes.UpdatePos:InvokeServer(Handle.Parent, Handle.Parent.PrimaryPart.Position, PlayerMouse.Hit.p)
PreviousMouseHitP = PlayerMouse.Hit.p
end
end
end)
end)
--wait(.5)
It works but is, of course, not ideal as I'm invoking a RemoteFunction every render frame. Is there any way other that I could do this? Thanks.
