I have a model which needs to be welded to the player's left arm, and I want it to face the front of it.
This was the old script, but it only worked if the player doesn't move after spawning. If the player turns before the object is welded, the object will not be placed facing the front of the arm.
wait() local char = plr.Character local c = game.ServerStorage["Object Name"]:Clone() local weld = Instance.new("WeldConstraint") local armPos = char["Left Arm"].Position weld.Parent = c.Base weld.Part0 = c.Base c.Base.CFrame = CFrame.new(armPos,Vector3.new(armPos,armPos,armPos))*CFrame.Angles(math.rad(0),math.rad(180),math.rad(0)) weld.Part1 = char["Left Arm"] c.Parent = char
I want it to always face the front, even if the player is laying down. I tried doing this, but it still works the same.
local char = plr.Character local c = game.ServerStorage["Object Name"]:Clone() local weld = Instance.new("WeldConstraint") local armPos = char["Left Arm"].Position weld.Parent = c.Base weld.Part0 = c.Base c.Base.CFrame = CFrame.new(armPos,Vector3.new(armPos.x,armPos.y,armPos.z-1)) weld.Part1 = char["Left Arm"] c.Parent = char
I'm not good with CFrames, sorry if this is something easy but I have no idea of what to do. Thank you in advance.
I suggest you try work with CFrame.Angles(),
but to make it easier, use math.rad(). Like so:
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Part = Instance.new('Part', workspace) Part.CanCollide = false Part.Anchored = false local Weld = Instance.new('Weld', Part) Weld.Part0 = Part Weld.Part1 = Character:WaitForChild('Left Arm') Weld.C0 = CFrame.new(0,0,0) * CFrame.Angles(math,rad(0), math.rad(0), math.rad(0)) -- it will stay where the arm CFrame is, but you can rotate it using math.rad().