When it comes to smooth visuals, it would involve using local scripts to do it, which is often complex because it would have to be displayed equally to every client.
If I were to be in this case, I would make a folder named Pets inside of character model and put in the pets I want to tween. Then in a local script, I get every players’ character like this:
local function CharacterAdded(character)
-- Code here
end
local function PlayerAdded(player)
if player.Character then CharacterAdded(player.Character); end
player.CharacterAdded(CharacterAdded)
end
for _, player in pairs(PlayersService) do
PlayerAdded(player)
end
PlayersService.PlayerAdded(PlayerAdded)
In CharacterAdded, I would run a loop to get every pets from the Pets folder and begin tweening them.
I would also make player characters persistent if streaming is enabled to be safe about it.
I recommend to use align position for this.
It also makes the pet follow the player accurately without delay on the client too.
I changed your code to do this:
game.Players.PlayerAdded:Connect(function(plr)
local clonedParent = script.Parent:Clone()
clonedParent.Parent = workspace
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local connection
connection = game:GetService("RunService").Heartbeat:Connect(function()
if not char.Parent then
connection:Disconnect()
return
end
local att0 = Instance.new("Attachment")
att0.Parent = clonedParent
local att1 = Instance.new("Attachment")
att1.Parent = hrp
att1.CFrame = CFrame.new(-4, -1.6, 0)
local alingpos = Instance.new("AlignPosition")
alingpos.Parent = clonedParent
alingpos.Attachment0 = att0
alingpos.Attachment1 = att1
-- Tweak the properties to your liking.
local alingrot = Instance.new("AlignOrientation") -- Stops the pet from spinning around uncontrollably.
alingrot.Parent = clonedParent
alingrot.Attachment0 = att0
alingrot.Attachment1 = att1
-- Tweak the properties to your liking.
clonedParent:SetNetworkOwner(plr)
end)
end)
end)