So I made a weld script to weld a panel to the right side of the Right arm. But the Panel is welded in the middle of the RightLowerArm. How can I move it to the side? Example of what I want:
If your welding with a Weld Constraint
then you would want to manipulate the CFrame property of the Model via SetPrimaryPartCFrame
before welding it, however if your using the normal welds you can change the C0 property of the weld since the manages the CFrame property of the objects weld.
I know that I would have to do that but I don’t know how to code it to do that.
What type of weld are you using?
I am using a WeldConstraint. The arm Display is a model so I welded all the Parts inside the model to the main part which is the Part named Main:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
local RightLowerArm = Char:WaitForChild("RightLowerArm")
local ArmDisplay = game.ReplicatedStorage.ArmDisplay:Clone()
ArmDisplay.Parent = Char
ArmDisplay.PrimaryPart.Position = RightLowerArm.Position
local Weld = Instance.new("WeldConstraint", RightLowerArm)
Weld.Part0 = RightLowerArm
Weld.Part1 = ArmDisplay.PrimaryPart
end)
end)
Try something like this:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
local RightLowerArm = Char:WaitForChild("RightLowerArm")
local ArmDisplay = game.ReplicatedStorage.ArmDisplay:Clone()
ArmDisplay.Parent = Char
local Studs = CFrame.new(0,0,0) -- Axis order x,y,z (Your gonna have to mess around with this to get what you want)
local Angle = CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)) -- Axis order x,y,z (Your gonna have to mess around with this to get what you want)
ArmDisplay:SetPrimaryPartCFrame(RightLowerArm.CFrame * Studs * Angle)
local Weld = Instance.new("WeldConstraint", RightLowerArm)
Weld.Part0 = RightLowerArm
Weld.Part1 = ArmDisplay.PrimaryPart
end)
end)
2 Likes