- What do you want to achieve?
I want to make a gun like Jailbreaks. Only I’m not using a tool for this right now I just use a basic Raycast and mouse
- What is the issue?
I’m not sure how to make the bullet shoot in the direction of the mouse.
- What solutions have you tried so far?
Searched up some raycasting tutorials. and looked at api’s
This is as far as I have got but it does not shoot in the direction of the mouse.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local LocalPlayerGetMouse = LocalPlayer:GetMouse()
local PartVelocity = 1000
local Delay = 0
local Number = 1
local Folder = Instance.new("Folder")
Folder.Name = "Part's Folder"
Folder.Parent = workspace
while wait(Delay) do
local RayNew = Ray.new(LocalPlayerGetMouse.Hit.Position, Vector3.new(0, 0, 0))
Nil, Vector = workspace:FindPartOnRay(RayNew)
local Part = Instance.new("Part")
Part.Name = "Part" .. Number
Part.Position = Vector
Part.Velocity = LocalPlayer.Character.Head.CFrame.LookVector * PartVelocity + Vector
Part.Parent = Folder
Number += 1
en
If anyone could help that would be great!