Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I move a model with velocity without breaking it?

Asked by 3 years ago

Hi, I'm pretty new to scripting and was wondering if it's possible to move a model's individual parts with velocity without breaking it? What I'm trying to do is make a model that's launchable- so it's possible that I'm going in the complete wrong direction. However, with what I have right now (see below), I am able to get the individual parts to launch almost perfectly. My only issue is that the entire model just falls apart because they aren't anchored. Is there some way I can prevent this? Or perhaps a different approach?

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local FireEvent = ReplicatedStorage:WaitForChild('evt_fireBall') --remote event
local orb = game.Workspace.Orb

FireEvent.OnServerEvent:Connect(function(player, mousePos)

    -- Create new object
    local proj = orb:Clone()
    local caster = Instance.new('StringValue')
    local parts = proj:GetDescendants()
    local speed = 500

    --Caster info
    caster.Value = player.Name
    caster.Name = 'Caster'
    caster.Parent = proj

    --proj info
    proj.Name = 'proj'
    proj.Parent = game.Workspace
    proj.PrimaryPart = proj.nCircle

    --unanchor + moving the projectile
    for i , v in pairs(parts) do
        if v:IsA("BasePart") then
            v.Anchored = false
            v.Velocity = v.CFrame.lookVector * speed
            v.CFrame = CFrame.new(player.Character.RightHand.Position, mousePos)
        end
    end


    --Moving the proj


    --Attach damage script
    local projScript = game.ServerStorage:FindFirstChild('FireBallDamage'):Clone()
    projScript.Parent = proj

end)

I'm not sure if all that code is necessary but I thought I'd give you all that I have, just incase.

Answer this question