Search code examples
luarobloxluau

How i can make the parts of a Model be together with primarypart and follow it


I want to make a vfx model primary part go to the Player Character Primary Part, but the parts of the vfx model isn't moving with the model primary part. I tried to weld them but didnt work. What can i do? Code below:

local replicated = game.ReplicatedStorage
local powers = replicated.Powers
local ss = game.ServerStorage
local FireWind = ss.FireWind:Clone()

powers.GiantFire.OnServerEvent:Connect(function(Player, Hit)
    local char = Player.Character or Player.CharacterAdded:Wait()
    local hrpp = char.PrimaryPart
    local SuperFireSphere = Instance.new("Part")
    SuperFireSphere.Shape = Enum.PartType.Ball
    SuperFireSphere.Material = Enum.Material.Neon
    SuperFireSphere.BrickColor = BrickColor.new("New Yeller")
    SuperFireSphere.Anchored = true
    SuperFireSphere.CanCollide = false
    task.wait(.2)
    hrpp.Position += Vector3.new(0, 50 , 0)
    hrpp.Anchored = true
    SuperFireSphere.Parent = workspace
    FireWind.PrimaryPart.Position = hrpp.Position
    FireWind.Parent = workspace
    SuperFireSphere.Position = char.PrimaryPart.Position + Vector3.new(0,15,0)
    for i = 1, 10 do
        task.wait(.1)
        SuperFireSphere.Size += Vector3.new(2,2,2)
    end
    task.wait(10)
    SuperFireSphere:Destroy()
    hrpp.Anchored = false
end)

Solution

  • You should try set the PrimaryPartCFrame using model:SetPrimaryPartCFrame(cframe)

    In this case, you want it to follow the HumanoidRootPart CFrame.

    local model = workspace.Model
    local char = game.Players.LocalPlayer:WaitForChild('Character')
    local hrp = char.HumanoidRootPart
    local part = workspace.Part
    
    model:SetPrimaryPartCFrame(hrp.CFrame) -- sets the model's primary part's CFrame to the hrp.