Does anyone know why this Happens when I try Change the position with Tween Service
What im Trying to do is it stays on the arm grows but i cant keep it as just grows as it makes it stay in the middle not go along with the arm but when i do it it just Tps randomly over in a random direction and not what i put anyone know why?
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Event = RS:WaitForChild("Events"):WaitForChild("Gomu")
local Tool = script.Parent
Event.OnServerEvent:Connect(function()
local Character = Tool.Parent
local RightArm = Character:WaitForChild("Right Arm")
local RightArmPart = Instance.new("Part")
RightArmPart.Material = Enum.Material.SmoothPlastic
RightArmPart.Name = ("RightArmPart")
RightArmPart.Massless = true
RightArmPart.CFrame = RightArm.CFrame
RightArmPart.Size = RightArm.Size
RightArmPart.CanCollide = false
RightArmPart.Anchored = false
RightArmPart.Orientation = RightArm.Orientation
RightArmPart.Color = RightArm.Color
RightArmPart.Parent = workspace
local weld = Instance.new("ManualWeld")
weld.Part0 = RightArmPart
weld.Part1 = RightArm
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
local TweenService = game:GetService("TweenService")
local PistolInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local Armgoal = {
Position = RightArmPart.Position + Vector3.new(0, -100, 0)
}
local PistolTweenPosition = TweenService:Create(RightArmPart, PistolInfo, Armgoal)
local PistolTweenSize = TweenService:Create(RightArmPart, PistolInfo, {Size = Vector3.new(1, 10, 1)})
PistolTweenSize:Play()
PistolTweenPosition:Play()
end)
What exactly is the problem? Could you elaborate a little bit more about the problem?
Basically im trying to make it so my arm grows so i make a part attach it to my arm and make it grow however if i just leave it as increasing in size it will be in the middle so im trying to push it forward with tweenPosition so its like an arm howver the arm randomly floats in a different direction
im not sure if this makes sense
I would use render stepped, position the arm with CFrame and then add half of its length size instead. Then even if you just grow it, it’ll stay where it’s supposed to be.
alr ima have a look now thanks
Would you mind showing me an example of RenderStepped as im trying to implement it rn and its my first time using it
Wait is the arm suppose to be client sided or server sided?
Server Sided i Just tried it now and it sayed it can only be fired from local So rip
Do you know any other way to do this then without renderStepped?
Main Method
This is how you’ll be positioning it, it won’t be as smooth but it’ll get the job done, I’ll quickly go experiment with a few ideas to try and make a much smoother method but use this in the meantime:
task.spawn(function()
while wait() do
local TweenService = game:GetService("TweenService")
local PistolInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local PistolTweenSize = TweenService:Create(RightArmPart, PistolInfo, {
Size = Vector3.new(1, 5, 1),
CFrame = RightArm.CFrame * CFrame.new(Vector3.new(0,RightArmPart.Size.Y/2, 0))
})
PistolTweenSize:Play()
end
end)
Full Script
Edit: Fixed position bug + make a smoother movement.
local Character = workspace.Dummy
local RightArm = Character["Right Arm"]
local RightArmPart = Instance.new("Part")
RightArmPart.Anchored = true
RightArmPart.CFrame = RightArm.CFrame
RightArmPart.Material = Enum.Material.SmoothPlastic
RightArmPart.Name = ("RightArmPart")
RightArmPart.Massless = true
RightArmPart.Size = RightArm.Size
RightArmPart.CanCollide = false
RightArmPart.Orientation = RightArm.Orientation
RightArmPart.Color = RightArm.Color
RightArmPart.Parent = workspace
task.spawn(function()
while wait() do
local TweenService = game:GetService("TweenService")
local PistolInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local PistolTweenSize = TweenService:Create(RightArmPart, PistolInfo, {
Size = Vector3.new(1, 5, 1),
CFrame = RightArm.CFrame * CFrame.new(Vector3.new(0,RightArmPart.Size.Y/2, 0))
})
PistolTweenSize:Play()
end
end)
So i tried this but now its not doing anything its just like only with the TweenSize
What do you want the thing to do once it’s done its thing, is this a viewport, attack animation, just longer arms, etc? Because each of these has a completely different approach.
AttackAnimation Ill Show a vid of what im trying to do
Grow Arms and Retract But Im not Doing Retract Yet i just wanna know how to make it Extend
I see, I fully understand what you’re trying to make now and can figure a conclusion, give me a moment.
I think what you can do is make it increase in size, and offset the position too. When you increase the size of an object, the center is the position, and it will stay there. So since the very center is the position, when you increase the size by 1 stud on one axis, if you want one side to stay where it is, the position must be shifted forwards 0.5 studs to compensate for this, as it would extend by 0.5 studs on both sides.
Edit: I think the weld is the reason it keeps teleporting whenever you try. Maybe instead you could just set its position every frame relative to the arm.
1 Like
Yea that’s what I already tried showing but the main problem appears to be when the player moves the arm will look janky when it tries to get back aligned with the arm.
Do you know a solution to that perhaps?
1 Like
Did you set its position every frame? I’m thinking maybe have an offset variable. So when the arm is rotated, the length of the arm is on multiple axis. We could use trigonometry to calculate how much on each axis we go. The length of the arm will be the hypotenuse, although the position is halfway so half of it will be the hypotenuse. We will get the orientation of the arm. Let’s work on 2 dimensions to make this easier, and then go to 3 when we have the solution to 2.
It’s kind of hard to visualise it by reading text, so I’m sorry if this will be hard to follow along. sin(armOrientation) will equal the x axis divided by half of the arm length. Multiply by the arm length to get the x axis. cos(armOrientation) will equal the y axis divided by half of the arm length. Multiply by the arm length to get the y axis. If you remember soh cah toa, sin(theta) is opposite over hypotenuse, etc. We’ve solved for 2 dimensions.
Now for 3 dimensions. I haven’t really thought this far yet, but I’m sure you can just repeat what we did for 2 dimensions somehow.
I think this has been forgoten now lol
Well I Fixed it so thanks everyone it was actually extremely simple aswell
All i had to do was Tween The Weld
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Event = RS:WaitForChild("Events"):WaitForChild("Gomu")
local Tool = script.Parent
Event.OnServerEvent:Connect(function()
local Character = Tool.Parent
local RightArm = Character:WaitForChild("Right Arm")
local RightArmPart = Instance.new("Part")
RightArm.Transparency = 1
RightArmPart.Material = Enum.Material.SmoothPlastic
RightArmPart.Name = ("RightArmPart")
RightArmPart.Massless = true
RightArmPart.CFrame = RightArm.CFrame
RightArmPart.Size = RightArm.Size
RightArmPart.CanCollide = false
RightArmPart.Anchored = false
RightArmPart.Orientation = RightArm.Orientation
RightArmPart.Color = RightArm.Color
RightArmPart.Parent = workspace
local weld = Instance.new("ManualWeld")
weld.Part0 = RightArmPart
weld.Part1 = RightArm
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
local TweenService = game:GetService("TweenService")
local PistolInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true, 0)
local ArmSpeed = Vector3.new(0,0,10)
local PistolTweenSize = TweenService:Create(RightArmPart, PistolInfo, {Size = Vector3.new(1,50,1)})
local TweenPos = TweenService:Create(weld, PistolInfo, {C0 = CFrame.new(0, 24, 0)}):Play()
PistolTweenSize:Play()
wait(0.6)
RightArmPart:Destroy()
RightArm.Transparency = 0
end)