What are you trying to adjust the angle between? In a Weld there are two CFrames, complete orientations, that describe the parts’ offsets from the center of the weld. For an angle to be relevant in 3D you need an axis of rotation, x, y, z, or otherwise. Are you wanting to rotate one part around the first? Or close the angle from the center of the weld to each part?
A picture of what you are trying to achieve and what you have may help.
I am trying to rotate the weld accordingly to move an entire model which is welded to player’s arm. But I don’t want to rotate it ‘instantly’, I want to to rotate smoothly until it hits it’s desired rotation. Which I tried doing in the repeat() until.
Here is what I am trying to achieve picture wise:
The gun itself is welded onto the right arm, I want to rotate the weld to where the gun is angled forward.
I see. A lot of variables still exist like what part of the gun is welded to the arm, the orientation of the part (which way is the x, y, z axis), and the orientation of the arm (I’m not familiar with the default orientation). In addition to make this transformation easier the Weld center orientation should be at the center of rotation and the z axis should be the axis of rotation (to the left of the character). You can then use the following to rotate the weapon one degree:
local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
local Weld = script.Parent
TweenService:Create(Weld,Tweeninfo,{C0 = Weld.C0*CFrame.Angles(0,math.rad(90),0)}):Play()
For some reason the tween doesn’t seem to work, have I done something wrong here?
local tweenProperties = {
C0 = CFrame.new(.45,.5,.4) * CFrame.Angles(math.rad(35), math.rad(50), math.rad(45))
}
local tweenInfo = TweenInfo.new(
1, -- Tween Length
Enum.EasingStyle.Linear, -- Style
Enum.EasingDirection.Out, -- Direction
0, -- How many times it repeats Tween
false, -- Reverse tween after complete
0 -- Should it have a delay
)
local tween = TweenService:Create(weld, tweenInfo, tweenProperties)
tween:Play()
local TweenService = game:GetService("TweenService")
local weld = Instance.new("Weld")
weld.Parent = game.Workspace.Part
weld.Part0 = game.Workspace.Part
weld.Part1 = game.Workspace.Part2
wait(2)
local tweenProperties = {
C0 = CFrame.new(.45,.5,.4) * CFrame.Angles(math.rad(35), math.rad(50), math.rad(45))
}
local tweenInfo = TweenInfo.new(
1, -- Tween Length
Enum.EasingStyle.Linear, -- Style
Enum.EasingDirection.Out, -- Direction
0, -- How many times it repeats Tween
false, -- Reverse tween after complete
0 -- Should it have a delay
)
local tween = TweenService:Create(weld, tweenInfo, tweenProperties)
tween:Play()
I did not run into any issues. Are your parts anchored? As welds do not work with both parts being anchored.
Looks like you’re using welds, If I recall correctly, welds are meant to be replaced with WeldConstraints as they are more flexible and easier to use.
What I suggest doing is switching over to weld constraints, what you would do is CFrame or Position your model to your desired location and then add a weld constraint:
-- After you position and parent the gun:
local constraint = Instance.new("WeldConstraint")
constraint.Part0 = gunHandle
constraint.Part1 = localPlayerHand
constraint.Parent = gunHandle
WeldConstraints are easier to modify the CFrame and Position as well. For more information look here:
They provide examples of how to edit the position of the welded parts after it being welded.
EDIT: I believe weld constraints can also be tweened.
if WeldAction == 'SlopeArms' then
local tweenProperties = {
C0 = CFrame.new(.45,.5,.4) * CFrame.Angles(math.rad(35), math.rad(0), math.rad(0))
}
local tweenInfo = TweenInfo.new(
1, -- Tween Length
Enum.EasingStyle.Linear, -- Style
Enum.EasingDirection.Out, -- Direction
0, -- How many times it repeats Tween
false, -- Reverse tween after complete
0 -- Should it have a delay
)
local tween = TweenService:Create(weld, tweenInfo, tweenProperties)
tween:Play()
end
Do keep in mind, I have used prints to make sure it does run through and pass the if statement.
Im guessing here that you have got the tweenservice, so from what i see, does it actually show anything? Try adding in some print function around the code to see if it fires. Because this should work. BTW welds are not ment to be replaced with a weldconstraint. They are harder to use if you want to CFrame an object.