Can't move part in lookvector using TweenService

I’m trying to make a part named effect move forward in the LookVector of root (humanoidrootpart, properly defined)

for some reason, my code doesn’t work. it doesn’t error and once launched it just stays still. Here is my code

local distance = 10 
		local duration = 2
		
		local lookVector = root.CFrame.LookVector
		local targetPosition = root.Position + (lookVector * distance)

		-- Create the tween info
		local tweenInfo = TweenInfo.new(
			duration, -- Time
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.Out,
			0,
			false,
			0 
		)

		local target = {}
		target.Position = targetPosition

		local tween = game:GetService("TweenService"):Create(effect, tweenInfo, target)

		tween:Play()

wait nevermind it works… roblox studio was just bugging sorry

-- game.Loaded:Wait()

local local_player = game:GetService("Players").LocalPlayer
local character = local_player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")

function shoot_projectile(distance)
	local part = Instance.new("Part")
	
	part.Anchored = true
	part.CanCollide = false
	part.Parent = workspace
	
	part.CFrame = humanoid.RootPart.CFrame
	part.Orientation = humanoid.RootPart.Orientation
	
	local root_part = humanoid.RootPart
	
	game:GetService("TweenService"):Create(part, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
		Position = root_part.Position + (root_part.CFrame.LookVector * distance)
	}):Play()
	
	game:GetService("Debris"):AddItem(part, 2)
end

while task.wait(2) do
	spawn(function()
		shoot_projectile(math.random(1, 100))
	end)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.