I have currently came across a problem in development where when I apply a VectorForce to an NPC (via the server), it does not replicate on the server. In addition, the client believes it has ownership over the NPC regardless of my setting of :SetNetworkOwner(nil) on each basepart of the NPC via the server.
My goal is to replicate the VectorForce on the server’s end while maintaining my current NPC set up.
I have tried debugging by:
- Disabling the client’s animation on the NPCs.
- Checking for other server-based scripts that set network ownership
- Enabling owner visualizer to view the perceived ownership of each part on both the client and server
From the client perspective:
Client Perspective
From the server’s perspective:
Below is the snippet of code that set’s network ownership of the NPC.
for _,Child in pairs(Character:GetDescendants()) do
if Child:IsA("BasePart") then
if Child ~= RecognizationRadiusPart then
Child.CollisionGroup = "NPC"
end
if Child ~= Character.PrimaryPart then
Child.CanTouch = false
local Highlight = Instance.new("Highlight")
Highlight.Adornee = Child
Highlight.DepthMode = Enum.HighlightDepthMode.Occluded
Highlight.Enabled = false
Highlight.Parent = Child
end
Child:SetNetworkOwner(nil)
Child.Massless = true
end
end
Below is the VectorForce function (Part represents the NPC’s HumanoidRootPart)
local VectorForce = Instance.new("VectorForce", Part)
local ForceAttachment = Instance.new("Attachment", Part)
VectorForce.Attachment0 = ForceAttachment
VectorForce.Force = Direction.Unit*Force
if TweenData then
TweenService:Create(VectorForce, TweenData, {Force = Vector3.zero}):Play()
else
TweenService:Create(VectorForce, TweenInfo.new(DestroyTime or 1, Enum.EasingStyle.Exponential), {Force = Vector3.zero}):Play()
end
VectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
DebrisService:AddItem(ForceAttachment, DestroyTime or 1)
DebrisService:AddItem(VectorForce, DestroyTime or 1)
Thank you.
Edit 1: Accidentally posted before finished & edited to completion.
Edit 2: Added gifs for context with owner visualization enabled.