CFraming a model with Offset

My code:
local remote = game.ReplicatedStorage.RemoteEvent

remote.OnServerEvent:Connect(function(plr)

local PS = CFrame.new(plr.Character.UpperTorso.Position) + Vector3.new(0, 1.2, 0)

game.Lighting.Assistant:Clone().Parent = plr.Character

wait(.1)

plr.Character.Assistant:SetPrimaryPartCFrame(PS)

end)

The issue with this is it won’t CFrame the model. I want it so the model will be above the shoulder whilst cloning so there’s other copies for other players to call. However what happens is it is capable of parenting the model to the local character as long as I don’t have plr.Character.Assistant:SetPrimaryPartCFrame(PS)

Hang on a second, why are you parenting game.Lighting to the plr.Character?

:thinking:

1 Like

Oh…I read the script and made edits in here then made the same edits in the actual script. Let me just edit that (I’ve tested it with game.lighting.assistant already and same result)

Try this:
local PS = plr.Character:GetPrimaryPartCFrame() * CFrame.new(0,1.2,0)

This will use the HRP(HumanoidRootPart) instead of the UpperTorso, you’ll probably have to recalculate it to CFrame.new(0,HRP.Size.Y/2,0)

Not to mention that you have to shift it over the shoulder by changing X. It is above shoulder level, misinterpreted.

On a side note, you should parent the clone last, here’s the rewritten code:

remote.OnServerEvent:Connect(function(plr)
    local HRP = plr.Character.HumanoidRootPart -- assume it already exist
    local PS = plr.Character:GetPrimaryPartCFrame() * CFrame.new(0, HRP.Size.Y/2, 0)
    
    local model = game.Lighting.Assistant:Clone()
    model:SetPrimaryPartCFrame(PS)
    model.Parent = plr.Character
end)
2 Likes

Thank you for the help! I have another question and I’m not sure if I’m allowed to…are we allowed to post replies asking one question or is it alright if I message you through the forum? (It’s one question and a bit I guess)

PM me directly through the forum, if you have more questions.

1 Like

The original code’s biggest issue, as far as I can see, is the wait(0.1) between calculating the PS CFrame and applying it. This gives the character at least 6 frames to move by time it’s applied, so it’s not necessarily even still above them. It also means if the Assistant thing is unanchored it has time to fall due to gravity. Is it ever properly attached to the character by a weld or anything?