I’m trying to weld a gun magazine to the player’s left hand during an animation, it works, however, the position of the mag changes depending on the direction the player is standing in. How can I fix this?
This is the issue:
This is the code I’m using:
ReloadAnim:GetMarkerReachedSignal("MagGrab"):Connect(function()
TempMag = Mag:Clone()
local MagWeld = Instance.new("WeldConstraint")
MagWeld.Parent = TempMag
if Character:FindFirstChild("LeftHand") then
MagWeld.Part0 = Character:FindFirstChild("LeftHand")
MagWeld.Part1 = TempMag
TempMag.CFrame = CFrame.new(Character:FindFirstChild("LeftHand").Position) * CFrame.new(0.2, 0, 0.1) * CFrame.Angles(0, math.rad(-90), 0)
else
TempMag:Destroy()
end
TempMag.Parent = workspace
end)
This is the first time I’ve made a scripting support post, so if I made any mistakes, please let me know!
It’s just unnecessary processing the game has to do. It’s small but it’s a good habit. Why tell the game to calculate how much 90° is in radians when you already know the answer is math.pi / 2? Just to clarify math.rad(-90) will return you -math.pi / 2. So you can just replace it.