How can i fix "projectile" part going in a wrong direction?

Hello DevForum how can i fix this (Shown in the video)

Here is camera script

local Camera = workspace.Camera
local Tweens = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()

Camera.CameraType = Enum.CameraType.Scriptable

local CameraPart = Instance.new("Part")
CameraPart.Transparency = 1
CameraPart.CanCollide = false
CameraPart.Parent = workspace

CameraPart.CFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0, 30, 0), HumanoidRootPart.Position)

local Body = Instance.new("BodyPosition")
Body.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
Body.Parent = CameraPart

game:GetService("RunService").RenderStepped:Connect(function()
	Body.Position = HumanoidRootPart.Position + Vector3.new(0, 40, 0)
	Camera.CFrame = CameraPart.CFrame
	local Tween = Tweens:Create(HumanoidRootPart, TweenInfo.new(0.003), {CFrame = CFrame.lookAt(HumanoidRootPart.CFrame.Position, Vector3.new(Mouse.Hit.Position.X, HumanoidRootPart.CFrame.Position.Y, Mouse.Hit.Position.Z))})
	Tween:Play()
end)

And projectile script

local UIS = game:GetService("UserInputService")
local Redball = game.ReplicatedStorage.Bullet
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRoot = Character:WaitForChild("Torso")
local AppliedForce = 250
local Mouse = Player:GetMouse()

local db= false
local dbtime = 0.1

UIS.InputBegan:Connect(function(Input, IsTyping)

	if IsTyping then return end

	if Input.UserInputType == Enum.UserInputType.MouseButton1 then

		if db == false then 

			db = true

			local NewRedBall = Redball:Clone()
			NewRedBall.Parent = workspace    
			NewRedBall.CFrame = HumanoidRoot.CFrame * CFrame.new(0,0,-2)

			NewRedBall.BodyVelocity.Velocity = Character.Head.CFrame.LookVector * AppliedForce

			wait(dbtime)

			db = false
			wait(1) NewRedBall:Destroy()
		end
	end
end)
3 Likes

Try changing this to HumanoidRootPart. The projectile comes out from the torso, which is affected by animations.

2 Likes

Similarly this line uses the head’s CFrame, which is also affected by animations. Use HumanoidRootPart here too.

NewRedBall.BodyVelocity.Velocity = Character.Head.CFrame.LookVector * AppliedForce
2 Likes

Changed it but didnt do anything its still the same like in the video.

1 Like

Try what @gertkeno said instead.

Changed it too but still did not help.

Make the BodyVelocity.MaxForce property higher

Still did not helped with direction

Instead of using Head.CFrame.LookVector, I’d use Unit with HumanoidRootPart and Mouse, so something like this.

local Direction = (HumanoidRootPart.Position - Mouse.Position).Unit

If that doesn’t help then I would use Linear Velocity over the deprecated version of what you’re currently using.

Sorry for long answer! So it does work but is it possible to make it just go straight also i change abit


So in this video ^^ Iv changed Applied force to -250 Cuz our bullet part was sending always behind me (Video of it doing it at the bottom)

local Direction = (HumanoidRootPart.Position - Mouse.Position).Unit

To

local Direction = (HumanoidRoot.Position - Mouse.Hit.Position).Unit * AppliedForce

Is there a way to send part like this but in front of me?

To be honest I dont really get what you’re asking.

Why not just multiply direction by -1?

1 Like

I have tryed that but. When i click it sends part in to current mouse location so if i aim it on the ground part will be aimed there but i need to make part go like in this video

Like i need to make part just go in one line where player aims no to anywhere else