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?