-
What do you want to achieve?
Well I made a pet system which works totally fine but I just noticed testing it with a few players that whenever the pet get close to a character it starts to lag somehow and I want to know what is causing that -
What is the issue?
whenever I get close to a player character, if one of my pets touches it, it starts to lag
https://gyazo.com/aa7c763d88fe14fea46706f60d9342cc -
What solutions have you tried so far?
I have tried deleting each player bodypart or attachment one by one to see what is causing it but although nothing was left it still cause that unless nothing is there ofc
Hey. Can you provide the script? And do you use any Touch Events?
Well I actually do not use any touched events, the script is too long and theres some other things related to it so I’d rather not, I just need some theories on how I can fix this
As long as you dont send the code i cant really help you there. Sorry.
The simplest solution to this is to make the player and pets not able to collide with one another. I’ve had a similar problems with morphs, when they collide with other players it lags quite a bit. You can either just turn off “CanCollide” on all parts of your pets or use collision groups. If you want to go with collision groups, I’d recommend using a plugin to do so.
You want me to send 3 scripts with over 100 line each?
Ok, other question. Do you just set the position or do you use BodyForce and BodyGyro?
I actually use attachments and AlignPosition and Orientation to align them
I’ll try that out and tell you if it worked, ty!
To be more precise with how I’d do it personally, since the can collide on Head, Lower Torso, and UpperTorso parts within characters cannot be turned off via conventional means, would be as follows:
Using the Collision Group Editor Plugin, make two collision groups like so:

You could also uncheck the bottom left box if you’d like characters to not touch one another. All this setup is doing is making it so pets cannot touch each other and pets cannot touch characters. Both pets and characters would still be able to touch normal parts and as such wouldn’t fall through the map.
For your scripting portion, you just want to set all parts inside of characters to the characters collision group every time the character is spawned. You need to do the same for the pets as well, setting all their parts to the corresponding collision group every time its spawned in.
Well I actually had my pets cancollide off and that still happens
This happens because the network ownership of your pet changes from you to the other player. You can use BasePart:SetNetworkOwner(PLAYER) to force network ownership to a player.
Oh, that actually worked, it doesnt do it anymore ty! but just a quick question what does :SetNetworkOwner do and why does it change whenever my pet touches a player
This is because it involves something with calculating physics from a specific person, either the server or the client. If you let the client to calculate the physics, it would make the view from other clients look weird. If you set it to the server, the server will manage every single unacnhor part’s physics so it make sure that all client’s views are the same. For more informations, check in here.