How to make bullet shoot where u looking at

How to make the bullet shoot where u looking at , i dont know how to do it.

4 Likes

In the direction of the player’s mouse, or the direction of the player’s camera?

3 Likes

btw can you explain how to shoot bullet directly from camera direction ?

camera.cframe.lookvector * distance, something like this, i forgor :grey_question:

search it up before you post

1 Like

ohh ok for information !!! and thank you for repliying :slight_smile:

If you specify what thing you are shooting from (such as the guns barrel) and then have a clonable bullet, and a place you want it to be in front of (camera is what I did for my FPS) you can do something like this (this will not work, we are not permitted to give full scripts you need to learn yourself).

local newBullet = game.ReplicatedStorage.Bullet:Clone()

now that we have cloned the bullet it needs to go somewhere
(like the barrel a mentioned before, and then because we are setting position we can also set where the bullet’s looking at with the LookAt function if CFrame)

newBullet.Name = ("whatever name you want")
newBullet.CFrame = CFrame.new(yourbarrell.Position, YourCamera.CFrame.LookVector * anywhole number)

now that we have the bullets position and lookvector, we can add velocity to it.

newBullet.Velocity = youcamera.CFrame.LookVector * distance

whatever you put in the “distance” space will be how many studs it travels.
please check the devforum next time, there are probably hundreds of other posts on this topic.

4 Likes

ok you are so good scripter of roblox fps game :slight_smile:

umm what should i type in YourCamera? game.workspace.currentcamera?

1 Like

You could raycast towards the cameras lookVector * ALot.

like this?

local camera = game.workspace.currentcamera
newbullet.CFrame = CFrame.new(gunbarrel.Position, camera.CFrame.LookVector * 100?

2 Likes

Pretty much! Good luck.

SorryBroINeedChars

1 Like

then why my bullet go behind me ._.
Untitled

1 Like

nvm the bullet spawn infront of me and didnt shoot

1 Like

Try doing CFrame = CFrame.new(yourbarrell.Position, YourCamera.CFrame * CFrame.new(0, 0, number))

Please note that the number may need to be the negative version of it.

invalid argument #2 to ‘new’ (Vector3 expected, got CFrame)

newbullet.CFrame = CFrame.new(Char.Head.Position, camera.CFrame * CFrame.new(0, 0, 1))

1 Like

Sorry, I meant to say newbullet.CFrame = CFrame.new(Char.Head.Position, (camera.CFrame * CFrame.new(0, 0, 1)).Position)

yay my fps gun finally work !!!

wherever i shoot the bullet , the bullet alway shoot at one direction

@MadionChooi you need to use newBullet.CFrame = Tool.Handle.Position, cam.cframe.lookVector * distance.

Please answer to me these 2 questions :
1 ; Is the script a local script?
2 ; Are you using first person arms?