I know this is talked about alot on the Forums, but I’m looking for ways to create a Pet / Follower system. Almost ALL of the tutorials and discussions refer to pets that float and follow the Player - I’m looking to create a Pet system that follows and walks behind the Player.
In the link below you can see a method I had done using Humanoids etc. However, I’m looking to rely on AnimationControllers and have the Pet follow without the use a Humanoids :MoveTo() function.
I’ve seen games suches as:
ClubRoblox and Loomian Legacy that demonstrate the idea I’m referring to.
I am on mobile right now so cannot demonstrate physically.
My current method:
Followers have a Humanoid within them, their parts Ownership are set to the Player and the Followers :MoveTo() is managed via the client.
What I would do is to create a part welded to your character and with your pet object, put a bodyposition inside it and set the position to be the position of the part welded. You could create a simple loop for this so that the pet will always follow. If you don’t want it to float then make a hummanoid and just the objects the pet, and make it follow the welded part by :MoveTo()
I set the network owner to the player and then control all movement from a local script in starter gui via renderstepped function, it works good for me, have you tried this?
However @Instance0new solution would also not show the pets for everyone, only that player unless you fired an event to get the server to replicate it to all clients.
Any changes in a local script only affect that client thus if an exploiter changed the size to inf and cloned it would only affect them. If you are replicating it to the server then some simple sanity checks on the server would prevent this. This principle comes back to NEVER trust the client.
No, network ownership only causes the physics calculations to be carried out on the device you set it to (the client in this case) so it looks smoother to the client because the results of the calculations do not have to be sent to the client.
Normally (and by default) the server has network ownership to prevent too many calculations being carried out on the client and creating unnecessary lag.
you can only set network owner from server so yeah it would show up because the way i do it is when a character gets added and data is loaded then all ur pets get cloned to a pets folder in workspace, then the client script sorts through that folder updating the pets position every frame.
If it is just the pets then no, it won’t lag, what I meant and I should have clarified more (bad me) is that you don’t set network ownership of everything to the client because then it will lag.
There are AlignOrientation and AlignPosition constraints that might be of use if they float. If not those, you could just manually manipulate the CFrame of the pet.
If you want them to follow in a line, you could try using arrays to assign some sort of order to them so they do not run into each other. If you want them to float around you, try keeping them within a specific radius or offsetting them based on how many already are equipped.
If you want them to walk behind you, you can also keep track of the player’s position over time in a small array. That way the pets know where to walk as to not be lost. My old pet system made them hop to the next stud the player has walked on in the position array.
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local isPet = script:WaitForChild("isPet").Value
local isMoving = Instance.new("BoolValue")
local Distance = 5
local WalkAnim = isPet["Humanoid"]:LoadAnimation(script["Animations"]["Walk"])
isPet["Humanoid"].Running:connect(function(speed)
if speed >= 5 then
--WalkAnim:Play()
else
--WalkAnim:Stop()
end
end)
game:GetService("RunService").RenderStepped:Connect(function(Step)
if (isPet["HumanoidRootPart"].Position - Character["HumanoidRootPart"].Position).Magnitude > 50 then
isPet:MoveTo(Character["HumanoidRootPart"].CFrame.p - Character["HumanoidRootPart"].CFrame.LookVector * Distance)
end
if (Character["HumanoidRootPart"].Velocity).Magnitude >= 0 then
isPet["Humanoid"]:MoveTo(Character["HumanoidRootPart"].CFrame.p - Character["HumanoidRootPart"].CFrame.LookVector * Distance)
end
end)