Align position lagging for 5 seconds

Hello, I was working on a pet system and I used Align positions and align orientations but for some reason the pet lags for the first 5 secods here is what I mean:


And after that it works fine, here is my script:

local ts = game:GetService('TweenService')

local tweeninfo = TweenInfo.new(
    2.4,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.InOut,
    -1,
    true,
    0
)



game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local pet = game.ReplicatedStorage["Mythical Demon"]:Clone()
        pet.Parent = workspace
        pet.Name = 'Pet'

        pet:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame)

        local at = Instance.new('Attachment', char.HumanoidRootPart)
        at.Position = Vector3.new(4,4,4)

        local ap = Instance.new('AlignPosition')
        ap.RigidityEnabled = true

        ap.Parent = pet
        ap.Attachment0 = pet.PrimaryPart.Attachment
        ap.Attachment1 = at

        local ao = Instance.new('AlignOrientation', pet)
        ao.RigidityEnabled = true
        ao.Attachment0 = pet.PrimaryPart.Attachment
        ao.Attachment1 = at
        wait()
        local YTween = ts:Create(pet.PrimaryPart.Attachment, tweeninfo, {Position = pet.PrimaryPart.Attachment.Position + Vector3.new(0,2,0)})
        YTween:Play()


    end)
end)

Thank you !

Try pet.PrimaryPart:SetNetworkOwner(plr) after you parent it to workspace.

Also no reason to have a wait() there BTW.

5 Likes