Problem with direction variable

I tried calculating a Vector Force by a Direction variable, I want it to go straight were the HumanoidRootPart is looking. Here is the code:

local direction = (humanoidRootPart.CFrame.LookVector * Vector3.new(1, 0, 1)).unit

If someone needs here is full code

	local function DestroyConstraints(char)
			if char:FindFirstChild("Bubble") then
				local bubble = char:FindFirstChild("Bubble")
				for _, constraint in ipairs(bubble:GetChildren()) do
					if constraint:IsA("WeldConstraint") then
						constraint:Destroy()
					end
				end
			end
		end

		local bubbleTemplate = game.ServerStorage.Bubble
		if bubbleTemplate then
			local bubble = bubbleTemplate:Clone()
			local TweenService = game:GetService("TweenService")
			bubble.Parent = workspace
			bubble.CFrame = char.HumanoidRootPart.CFrame + Vector3.new(1,0,0)
			Hum:LoadAnimation(script.Bubble):Play()
			local tween = TweenService:Create(bubble,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0),{Size = Vector3.new(7.212, 7.212, 7.212)})
			tween:Play()
			tween.Completed:Connect(function()
				local force = Instance.new("VectorForce")
				local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
				local direction = (humanoidRootPart.CFrame.LookVector * Vector3.new(1, 0, 1)).unit 
				force.Force = direction / 2.6
				force.RelativeTo = Enum.ActuatorRelativeTo.World
				force.Parent = bubble

				local attachment = Instance.new("Attachment")
				attachment.Parent = bubble
				attachment.Position = bubble.Position
				force.Attachment0 = attachment
			end)

			local touchconn 
			touchconn = bubble.Touched:Connect(function(hit)
				if hit.Parent and hit.Parent ~= char and hit.Parent:FindFirstChild("Humanoid") then 
					local WeldConstraint = Instance.new("WeldConstraint")
					WeldConstraint.Parent = bubble
					WeldConstraint.Part0 = bubble
					WeldConstraint.Part1 = hit.Parent.Torso
					bubble.Parent = hit.Parent
				end
			end)

			wait(10)
			DestroyConstraints(char)
			touchconn:Disconnect()
			bubble:Destroy()
		else
			warn("Bubble template not found.")
		end
1 Like

90% sure you don’t need to multiply by a Vector3 and then get the unit. Just multiply it by a whole number.

local direction = (humanoidRootPart.CFrame.LookVector * 5)

This is how I do it for Raycasting, not too sure about VectorForce though.

1 Like

Now the ball dosen’t move but thanks for responding!