Gun system, projectiles

Hi, I’m working on a gun system (which works almost fine), the projectiles shoot in the direction of the mouse, but they don’t have the right orientation.

Its hard to explain, so here is a picture:
Screenshot (129)

As you can see, the projectile (the yellow part) is moving towards the mouse but is not facing forward, its facing sideward.

I tried this:
Bullet.CFrame = CFrame.new(Bullet.Position, mouse)
But it doesnt work, also, I’m handling the bullet on the server.

Here’s a link to the game, Because its hard to explain:

How can I do this?

Any help is much appreciated! :smiley: :+1:

Simple fix I think

local bullet = --put the bullet here or replace with your own variable however you store the bullet instance
bullet.CFrame = CFrame.new(bullet.Position, mouse.Hit.P)

I get this error:
Hit is not a valid member of Vector3 - Server - Shoot:43
I think that’s because I’m using a server script.

I’m handling the bullet on the server.

I think your getting that error because your assigning a Cframe to a position?

Why are you trying to do here? The first argument of CFrame is where you want the part to be positioned. The 2nd argument is where do you want it to look at.

Because mouse might be already defined and probably has a Vector3 value inside it.

I’m trying to make my projectile face the mouse.

Hey, do you have any footage of what’s happening here?

I don’t have any recording software, do you understand from the picture?

Not really. Use roblox’s default recording systen.

The projectile doesnt face forward when its being fired out of the gun, it faces sideways, that’s the problem, do you understand?

So, I’m asking how to make it face the mouse when its fired out if the gun.

Now I understand the problem, I’ll look into it.

Do you mean this. This is on the client but it works.

local Tool = script.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

Tool.Activated:Connect(function()
	local Bullet = Instance.new("Part")
	Bullet.CFrame = CFrame.new(Tool.Handle.Position, mouse.Origin.Position)
	Bullet.Name = "Bullet"
	
	local BV = Instance.new("BodyVelocity")
	BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	BV.P = math.huge
	BV.Velocity = mouse.UnitRay.Direction * 50
	
	Bullet.Parent = workspace
	BV.Parent = Bullet
end)

The bullet is positioned in the handle and travels to the position the mouse clicked.

I made that already, I’m just asking how to make the bullet orientation face the direction its moving to.

I already said earlier:

Maybe try this:
Bullet.CFrame = CFrame.new(Bullet.Orientation, mouse.Hit.Position)

That doesnt work, Because I don’t think Orientation is a member of CFrame.

I’ve tried it and it didn’t give me any errors, might be a coincidence at my end but maybe give it a shot.

I already tried it, and it didn’t work.

Wait, isn’t it that the mouse can only be accessed by the client?

I dont think you understand my problem, I made a working gun system, everything works fine, I just need the bullets orientation to face the mouse.