I'm currently trying to figure out how I can make a part stay behind a player. Even if the player turns around, the part will turn with it along the center of the torso part. I want to accomplish this with CFrame:toWorldSpace() and CFrame:toObjectSpace(), but I have no clue how to set and change CFrame ObjectSpace Values. This is what I've got so far. This will indeed make the block stay around the player, but it doesn't stay behind the player when he turns.
So does anyone have an idea where I should put either CFrame:toObjectSpace or CFrame:toWorldSpace?
_G.Block = {} _G.Block.Free = true _G.Block.Character = nil script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= _G.Block.Character then script.Parent.Parent = hit.Parent _G.Block.Free = false _G.Block.Character = hit.Parent local weld = Instance.new("ManualWeld") weld.Part0 = script.Parent weld.Part1 = _G.Block.Character.Torso weld.C0 = CFrame.new() weld.C1 = _G.Block.Character.Torso.CFrame:toObjectSpace(script.Parent.CFrame) weld.Parent = script.Parent end end)
Thanks in advance
Firstly, I would just use a normal Weld instead of a manual weld. Second, try this. You may have to mess about with the values of the weld's C1. You may either have to make the number positive, change the axis, adjust the number or even do all of these. All you need to do is to just experiment when it comes to welds.
_G.Block = {} _G.Block.Free = true _G.Block.Character = nil script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= _G.Block.Character then script.Parent.Parent = hit.Parent _G.Block.Free = false _G.Block.Character = hit.Parent local weld = Instance.new("Weld") weld.Part0 = _G.Block.Character.Torso weld.Part1 = script.Parent weld.C0 = CFrame.new() weld.C1 = CFrame.new(-0.5,0,0) --Change this to suit your specification. weld.Parent = script.Parent end end)