Tweening Part Resize Forwards

I was trying to make like dash with tween like this:

But this was happening:

After that I was looking to solve this problem on devforum and then i found that i need to use CFrame

local goal = {Size = clone.Size + Vector3.new(50, 0, 0), CFrame = clone.CFrame * CFrame.new(25, 0, 0)}

with this script only works size but CFrame doesn’t

But that doesn’t work. Can somebody explain and help!?

1 Like
local dist = 25
{ Position =  playersHumanoidRootPart.Position + playersHumanoidRootPart.CFrame.LookVector * dist }

I can’t explain what exactly I wanted to do it’s not dash but I can show you in a broken way what I wanted to do:

Everything is ready like for example:

  • Dash function
  • UserInputService and etc

I just can’t move the part when it’s sizing

This is full script

local holding = ReplicatedStorage:WaitForChild("holding")
UserInputService.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.R and not gpe then
		local clone = holding:Clone()
		
		clone.Parent = player.Character.SheatheForKatana.storage
		local weld = Instance.new("Motor6D")
		weld.Part0 = player.Character.HumanoidRootPart
		weld.Part1 = clone.partneshto
		weld.C0 = CFrame.new(0,0,-0.5) * CFrame.Angles(0, 1.56, 0)
		weld.Parent = player.Character.HumanoidRootPart
		
		local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0 , false)
		local goal = {Size = clone.partneshto.Size + Vector3.new(50, 0, 0),  CFrame = clone.partneshto.CFrame * CFrame.new(25, 0, 0)}
		local tween = tweenService:Create(clone.partneshto, tweenInfo, goal)
		tween:Play()
	end
end)
1 Like

When you welded it to the HumanoidRootPart it rotates with it. I’d suggest just removing the whole object entirely and use beams instead which only needs two attachments. Here is my recreation:

If you want the thing to animate I guess just lerp the attachment to the enemy’s humanoidrootpart?
I’m not entirely sure if it’s gonna work nor do I have any fixes to your current system.

StartAttachment.Parent = player.Character.HumanoidRootPart
for i = 0, 1, 0.05 do
    EndAttachment.CFrame = EndAttachment.CFrame:Lerp(EnemyHRP, i)
    task.wait(1/60)
end
1 Like
-- This is all in the client I presume
local TweenService = game:GetService("TweenService")
local currentCamera = workspace.CurrentCamera

-- Attachments
local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
local EndAttachment = Instance.new("Attachment", otherPart)

local Beam = Instance.new("Beam", currentCamera)
Beam.Texture = "rbxassetid://0" -- Texture
Beam.FaceCamera = true
Beam.Attachment0 = StartAttachent
Beam.Attachment1 = EndAttachment

EndAttachment.WorldPosition = StartAttachent.WorldPosition
TweenService:Create(EndAttachment, TweenInfo.new(2), {Position = Vector3.new()}):Play() -- Tween it and stuff

Moving:
https://gyazo.com/622482737ffcbe7f844a954471bca9b4

Static:
https://gyazo.com/198053e8d45e51e3ab8fba288945b36b

Assuming you don’t want it to connect directly to the enemy player, you could just simply make another part, parent it in currentCamera and change the position the same way the dash did it in post 3:

local Part = Instance.new("Part", currentCamera)
Part.Anchored = true
Part.Transparency = 1

Part.Position =  player.Character:WaitForChild("HumanoidRootPart").Position + player.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * dist

local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
local EndAttachment = Instance.new("Attachment", Part)
1 Like

That was epic from what i made but


I was trying to change somthing on the script but i can’t from what i expected
I was trying to make when part goes forward to rotate with HumanoidRootPart like end of the video but only goes forward when I was pressed the button but when i was rotate:

only part rotate not rotating entire beam and part
I was trying to make is when player hold R when player rotates beam and part goes forward from player so player can knows where he can dash hit the target but not when part hit player to attach

this is the script:

local TweenService = game:GetService("TweenService")
local currentCamera = workspace.CurrentCamera

local holding = ReplicatedStorage:WaitForChild("holding")
UserInputService.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.R and not gpe then
		local clone = holding:Clone()
		
		
		local Part = Instance.new("Part", currentCamera)
		Part.Anchored = false
		Part.Transparency = 0

		Part.Position =  player.Character:WaitForChild("HumanoidRootPart").Position + player.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 2
		
		local weld = Instance.new("Weld",Part)
		weld.Part0 = player.Character.HumanoidRootPart
		weld.Part1 = Part
		local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
		local EndAttachment = Instance.new("Attachment", Part)
		
		local Beam = Instance.new("Beam", currentCamera)
		Beam.Texture = "rbxassetid://0" -- Texture
		Beam.FaceCamera = true
		Beam.Attachment0 = StartAttachent
		Beam.Attachment1 = EndAttachment
		
		TweenService:Create(Part, TweenInfo.new(2), {Position = 
                 Vector3.new(Part.Position.X,Part.Position.Y,-20)}):Play()
	end
end)

Sorry for bad english

Why does need to move forward to show player where he can hit the target,you can make it just disappear

Because i wanted to make when you hold R how much you hold more far you can dash

2 Likes
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local currentCamera = workspace.CurrentCamera

-- If there is a maximum dash distance then plug it into Part.Position
local configuration = {
	MaxDashDistance = 50
}

UserInputService.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.R and not gpe then
		local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart", 2)
		
		local Part = Instance.new("Part", currentCamera)
		Part.CanCollide = false
		Part.Massless = true
		Part.Transparency = 0.75

		Part.Position =  HumanoidRootPart.Position + HumanoidRootPart.CFrame.LookVector * configuration.MaxDashDistance

		local weld = Instance.new("WeldConstraint", Part) -- Change this to WeldContraint so the parts doesn't have to be touching for it to weld
		weld.Part0 = player.Character.HumanoidRootPart
		weld.Part1 = Part
		
		local StartAttachent = Instance.new("Attachment", HumanoidRootPart)
		local EndAttachment = Instance.new("Attachment", Part)
		EndAttachment.WorldPosition = StartAttachent.WorldPosition
		
		local Beam = Instance.new("Beam", currentCamera)
		Beam.Texture = "rbxassetid://0" -- Texture
		Beam.FaceCamera = true
		Beam.Attachment0 = StartAttachent
		Beam.Attachment1 = EndAttachment
		
		-- I would just try to tween the end attachment to the part (which is basically the maximum dash distance)
		-- then would cancel the tween using tween:Cancel() when the person stops holding R
		spawn(function()
			local tween = TweenService:Create(EndAttachment, TweenInfo.new(2), {
				Position = Vector3.new()
			}) tween:Play()
			
			-- Scuffed but it's what I can think of right now
			local inputEnded;
			inputEnded = UserInputService.InputEnded:Connect(function(input, gpe)
				if input.KeyCode == Enum.KeyCode.R and not gpe then
					-- Cancel the tween and set part position to EndAttachment.WorldPosition
					tween:Cancel()
					Part.Position = EndAttachment.WorldPosition					
					
					
					
					--[[ EXECUTE DASH FUNCTION THING HERE ]]
					--local distance = (Part.Position - HumanoidRootPart.Position).Magnitude
					--Dash(distance)
					
					
					
					--[[ Cleanup ]]
					-- i don't know how you destroy the parts, attachments, and welds after so:
					Part:Destroy()
					weld:Destroy()
					StartAttachent:Destroy()
					EndAttachment:Destroy()
					Beam:Destroy()
					
					-- Disconnect connection
					inputEnded:Disconnect()
					inputEnded = nil
				end
			end)
		end)
		
	end
end)

If I understand you correctly, you want a visualization of how far a player dashes.

What this basically does is put the part at the maximum dash distance, then tweens the
endAttachment to the Part.

When the player stops holding R, it cancels the tween, and sets the part’s position to the endAttachment’s position.

Finally, we run the dash function, and we cleanup the instances.

2 Likes