Why can't i change the position of the Part

here is my script

newHeal.CFrame.X = char.HumanoidRootPart.CFrame.X
newHeal.CFrame.Z = char.HumanoidRootPart.CFrame.Z

what i want to do is the set the newHeal part to the charcter’s X and Z, but it have an error saying can’t apply to X

Can you please show me how you define char?

local char = plr.Character

and the way i define plr is
game.ReplicatedStorage.Heal.OnServerEvent:Connect(function(plr)

Ok try this:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local newHeal = --wherever this part is
        newHeal.CFrame.X = character:WaitForChild("HumanoidRootPart").CFrame.X
        newHeal.CFrame.Z = character:WaitForChild("HumanoidRootPart").CFrame.Z
    end)
end)

And is this a server script?

yes it is a server script and it still didnt work
X cannot be assigned to – have this error

You can’t change just a single CFrame number, you have to create a new CFrame and switch from there

local RootCFrame = char.HumanoidRootPart.CFrame
newHeal.CFrame = CFrame.new(RootCFrame.X, newHeal.CFrame.Y, RootCFrame.Z)

Is this to have the part stay with the player right at the center of the HumanoidRootPart?
Why not just Weld it to the player?
If you do Weld it make sure to make the Part’s Massless property true

You cannot assign the “X” and “Z” values directly.

So how should i do it?

with that, the rotation would be change, how should i do it without changing it?

CFrame’s first parameter expects a vector3, the second parameter would take in rotation (as another vector3), if you dont want to rotate, and just set to XYZ you specified earlier, you just wrap them inside a vector3 as below

local RootCFrame = char.HumanoidRootPart.CFrame newHeal.CFrame = CFrame.new(Vector3.new(RootCFrame.X, newHeal.CFrame.Y, RootCFrame.Z))

use CFrame.Angles() and CFrame:ToOrientation()

local RootCFrame = char.HumanoidRootPart.CFrame
newHeal.CFrame = CFrame.new(RootCFrame.X, newHeal.CFrame.Y, RootCFrame.Z)*CFrame.Angles(newHeal.CFrame:ToOrientation())

You could also replace this with newHeal.CFrame.Rotation.