How to fix projectile lag

I wanted to make a grappling hook. Here is his script:

local function ReleaseHook(plr:Player,mouseHit:CFrame)
	local char = plr.Character
	local animator = char.Humanoid.Animator

	arrowWeld.Enabled = false
	char:SetAttribute("InAnim",true)
	
	arrow.CFrame = CFrame.lookAt(arrow.Position,mouseHit.Position)
	arrow.CanCollide = true
	arrow.Anchored = false
	arrow.Touched:Connect(function(hit)
		if hit:IsDescendantOf(char) then return end
		print(hit)
		arrow.Anchored = true
		for _,weld in arrow:GetChildren() do
			if weld:IsA("Weld") then
				weld.C0 = weld.CFrameValue.Value
			end
		end
		toolModule.ToolFunctions.GrapplingHook:CreateRope(tool)
	end)
	arrow.Parent.Parent = workspace.Debris
	arrow:SetNetworkOwner(nil)

	local force = Instance.new("VectorForce")
	force.RelativeTo = Enum.ActuatorRelativeTo.World
	force.Force = (mouseHit.Position - arrow.Position).Unit * 100
	force.Attachment0 = arrow:FindFirstChildOfClass("Attachment")
	force.Parent = arrow
	
	beam.Attachment0 = arrow:FindFirstChildOfClass("Attachment")
	beam.Attachment1 = primPart:FindFirstChildOfClass("Attachment")
end

But I was faced with the problem of distinction of positions on the server and client. (see the video). In the video in server side arrow touched the wall and arrow stopped. But on the client, the arrow did not have time to touch the wall, but already anchored. Let’s look at it from the side.


Looks how the problem of replication. But why the falling part replicated normal?

is this code localscript or normal script ?

OOUUUH, i forget attach how it work in far distance

can you share your explore ???

server script inside the tool (descendant of workspace)

I think don’t change the arrow’s Anchored.
Make it false.

what is the point if I need a character to attract to the arrow with a rope

reborn34.rbxl (4,0 МБ)
Animations here are almost not used, so get it. And to equip tool click LMB on the grappling hook in the table

Firstly, don’t use roblox’s physics engine, but rather make your own. Roblox’s Physics takes alot of Lag. Instead, you can do something like here:

Secondly, don’t run a unanchored object flying on server. That also causes a lag since it needs to replicate through every client. To fix that, you can do something like here:

i seen this videos, but tween service “defective”, when you need to pull the moving player or falling part

if so you can anchor the character then tween it to the last place the grapple hook landed i think

perhaps anchor if the hook actually grabs onto something then go on from there

Use body movers to constantly move the character to the direction of hook end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.