Recently I have been trying to tween the size and position of a part that is welded by script to the player. But I cannot seem to figure out why it does not tween the position of the welded part when I try to in the script.
I am pretty new to welds, and all the research on this topic has not given me an answer to my question. Maybe I am just doing it wrong and I am sorry if this has been posted before.
Here is the server script that clones the part and welds the part to the player, then tweens it.
Server Script:
-- Variables --
local TS = game:GetService("TweenService")
local SS = game:GetService("ServerStorage")
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("Activate")
local EffectPartsFolder = SS:WaitForChild("EffectParts")
local LeftArmPart = EffectPartsFolder.LeftArmEffectPart:Clone()
-- Main Function // Event Fire --
Event.OnServerEvent:Connect(function(Player)
local function WeldAndTween()
LeftArmPart.Parent = Player.Character["Left Arm"]
LeftArmPart.CFrame = Player.Character["Left Arm"].CFrame * CFrame.new(0, -0.2, 0) * CFrame.Angles(0, 0, 0)
local LeftArmWeld = Instance.new("Weld")
LeftArmWeld.Part0 = Player.Character["Left Arm"]
LeftArmWeld.Part1 = LeftArmPart
LeftArmWeld.C0 = Player.Character["Left Arm"].CFrame:Inverse()
LeftArmWeld.C1 = LeftArmPart.CFrame:Inverse()
LeftArmWeld.Parent = LeftArmPart
local LeftArmGoals = {
Size = Vector3.new(1.1, 2.05, 1.1);
Position = LeftArmPart.Position * Vector3.new(0, 0.2, 0)
}
local LeftArmTween = TS:Create(
LeftArmPart,
TweenInfo.new(0.8, Enum.EasingStyle.Quart),
LeftArmGoals
):Play()
end
WeldAndTween()
end)
I believe I’ve done everything right, because everything works besides the position changing which you can see I placed it here.
local LeftArmGoals = {
Size = Vector3.new(1.1, 2.05, 1.1);
Position = LeftArmPart.Position * Vector3.new(0, 0.2, 0)
}
Once again I am sorry if this has been posted before or answered already but I cannot find anything on the DevForum or the internet that helps my situation.
you see TweenService is only used for 1 Property so be careful when tweening an ObjectsProperties and your Usage of it is not correct try to recode it and see if it works!
Even if I placed them into separate tweens, it still does not change the position of the welded part, you see I am trying to make an effect from where it goes from the hand to the shoulder, but the position will not change.
I would tween the C0 property of the weld using TweenService. If you have a sequence of CFrames for the C0, I recommend making a new Tween via TweenService:Create() So that they override the previous one.
So it actually started moving it, which is great, any tips on how to calculate where it goes. As of now it’s weird and goes in different directions when I use this.
You could insert a dummy in the workspace, and move around the bodypart you want to be animated via the rotation and move tool in studio and print the offset of the said part into the output, record the output as a CFrame and use that.
For example in the picture below I rotated the arm with the move and rotate tool in studio.
C0 is basically the CFrame offset for Part1 from Part0 and C1 is the offset of C0(offset of the offset), but you don’t really need to use C1 at all for what you’re doing.
I think it makes a bit of sense to me, but I don’t understand it completely even after looking it up. But it seems to not do anything for me, as it still does the same thing shown below.
local info = TweenInfo.new(1, Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goals = {CFrame = Part.CFrame * CFrame.new(0,0,-5)
local Tween = game:GetService("TweenService"):Create(--YourPart,info,goals)
Tween:Play()
This is how I tween so. Wrote this on my phone might have some errors.
local cfValue = Instance.new('CFrameValue')
cfValue.Value = weld.C0
local base = weld.C0--the value all movement will be relative to
cfValue.Changed:Connect(function()
weld.C0 = cfValue.Value
end)
local goal = {Value = base * pos} --pos is the desired position relative to the base value
local cfTween = ts:Create(cfValue,info,goal)
cfTween:Play()
This just tweens a CFrameValue which is connected to the weld using Changed. When the CFrameValue changes, the weld’s CFrame changes.