Hello peoples. I am making a gun as I usually don't and I always run into the same problem, when running around or jumping, the ray is always like 3 or 4 studs away from the fire part of the gun. I have no idea how to fix this so any help is needed. Sorry for the short description. I'm not really sure what to say in this situation.
im just a scripting noob so plz help thx :D
This is the server script, the thing that shoots the ray: Just a little piece of it.
function fire(args)
local gunInfo = getToolInfo(args[3])
local ray = Ray.new(args[1].CFrame.Position, (args[2] - args[1].CFrame.Position).Unit * 300)
local part, position = workspace:FindPartOnRayWithIgnoreList(ray, returnIgnoreList())
local distance = (args[1].CFrame.Position - position).Magnitude
local laser = Instance.new("Part")
laser.Name = "Laser"
laser.Size = Vector3.new(0.03, 0.03, distance)
laser.CFrame = CFrame.new(args[1].CFrame.Position, position) * CFrame.new(0, 0, - distance/2)
laser.BrickColor = BrickColor.new("Daisy orange")
laser.Material = Enum.Material.Neon
laser.Transparency = 0.35
laser.CanCollide = false
laser.CastShadow = false
laser.Anchored = true
laser.Parent = workspace.RayIgnore
game:GetService("Debris"):AddItem(laser, 0.1)
end
And this is the client script, the thing that fires the event: Again, just a little piece.
function requestShot()
registerShot:FireServer({tool:WaitForChild("FirePart"), mouse.Hit.Position, tool})
requestAnimation("Recoil")
end
Any help is needed.

1 comment
When it's fired, Give the firepart CFrame first.