Hello, so, I’m making a turn based combat game, and in the overworld you’ll have followers which trail behind the party leader, like in mother 3 if you’ve played it. Now the scripts I have prepared for this work fine, however, there’s a visual issue that has been grinding at me for a while and I’m not really sure how to fix the problem. Follower #2 seems to delay following the party leader while follower #3 and onward have no issues of following the NPC infront of them, I think it has to do with the way the server responds or something because it only happens with NPCs following the player and not other NPCs. Also NPCs behind the player have a script in them that sets their network client ownership to NIL, so they don’t glitch-walk forwards when moving, and I’m 90% sure that may having something to do with it.
You can see in this video, the second follower takes a while to start following the player, while the third moves as soon as #2 moves, which makes the follower in the second slot trail way farther behind the party leader than it should be.
Sorry if my code is trash, this is the first time I’ve tried making something on my own.
Here’s like, the main follower code:
local ValuesFolder = script.Parent.Parent.Values -- this is just a big folder in the NPC which shows if they should be following somebody and who they should be following.
repeat wait() until ValuesFolder.WhoToFollow.Value ~= nil and ValuesFolder.SlotNumb.Value ~= 0 or nil -- waits until they're told to start following to function
local function Follow()
local SlotNumber = ValuesFolder.SlotNumb.Value -- which slot a character is in, 1 would be the playable character, and 2+ is an NPC follower.
local IsFollowing = ValuesFolder.IsFollowing.Value -- a bool. When true, follow the character infront.
local WhoToFollow = ValuesFolder.WhoToFollow.Value -- an object value of who they should be following if the slot is 2+.
local PartyMember = script.Parent.Parent
if ValuesFolder.IsFollowing.Value == true and WhoToFollow ~= nil then
local PartyMemberToFollowPosition = WhoToFollow.HumanoidRootPart.CFrame
local TargetPosition = PartyMemberToFollowPosition * CFrame.new((PartyMember.HumanoidRootPart.Position).Unit * 0,0,5) -- slight distance between characters.
PartyMember.Humanoid:MoveTo(TargetPosition.Position)
local DistanceFromPartyMemberToFollow = ((PartyMember.HumanoidRootPart.Position - TargetPosition.Position).magnitude)
if DistanceFromPartyMemberToFollow > 16.5 then -- only move if the distance is greater than that.
PartyMember.HumanoidRootPart.CFrame = TargetPosition
end
end
end
while true do -- I'm 90% sure this is a bad practice but I don't believe it's the issue, but if you have a better way of doing this I'd like to hear it anyways.
wait()
Follow()
end
Here’s the code for the network ownership script just incase:
local NPCparts = script.Parent.Parent:GetChildren()
wait()
for _, Item in ipairs(NPCparts) do
if Item:IsA("BasePart") or Item:IsA("UnionOperation") then
Item:SetNetworkOwner(nil)
end
end
Hopefully this post was able to clarify my issue, I haven’t made a post before so I’m sorry if I make any screw ups in the post itself.