#Issues with network ownership over model

4 messages · Page 1 of 1 (latest)

vivid field
#

I've been working on a throwing mechanic for a game I've been working on, and recently decided to implement a way to handle models being thrown by the player. This of course has proven to be a challenge all because of the network ownership system.

How the model system works is that it will take the tool model and somewhat reconstruct it into the workspace for it to be thrown. And to make the throwing not so laggy (as seen in the first video), I set the network ownership of the model's primary part. But this has proven to make the issue even worse as seen in the second video. After a little more testing I realized the issue was because of the server being out of sync with the client. But now I’m sitting here wondering what I should do in order to make the model be able to be tossed on the server while also being smooth on the client.

Any help is appreciated 😁

#

Here's the code:

local thrownObject = nil

    local function handleModels()
        local toolModel = tool:FindFirstChild("HandleModel");

        local newModel = Instance.new("Model");
        newModel.Name = "Thrown_" .. player.UserId;
        newModel.Parent = thrownBricksFolder;

        local handlePart = toolHandle:Clone();
        handlePart.CanCollide = false;
        handlePart.Parent = newModel;

        newModel.PrimaryPart = handlePart;

        for _, part: Part in pairs(toolModel:GetChildren()) do
            local newPart = part:Clone();

            newPart.Parent = newModel;
            newPart.CanCollide = false;
            newPart.Anchored = false;
            
            local partWeld = newPart:FindFirstChild("WeldConstraint");

            if partWeld then
                partWeld:Destroy();
            end

            local weld = Instance.new("WeldConstraint");
            weld.Part0 = newPart;
            weld.Part1 = newModel.PrimaryPart;
            weld.Parent = newPart;

            
        end

        newModel:PivotTo(toolHandle:GetPivot());
        newModel.PrimaryPart:PivotTo(CFrame.new(toolHandle.CFrame.Position, mousePosition));
        thrownObject = newModel.PrimaryPart;
    end

    handleModels();

    local attachment = Instance.new("Attachment");
    attachment.Name = "Attachment0";
    attachment.Parent = thrownObject;

    local BodyVel = Instance.new("LinearVelocity");
    BodyVel.MaxForce = 9000;
    BodyVel.VectorVelocity = thrownObject.CFrame.LookVector * 100;
    BodyVel.Attachment0 = attachment;
    BodyVel.Parent = thrownObject;

    game:GetService("Debris"):AddItem(BodyVel, 0.2);
lapis trellis
#

that might work