What do you want to achieve?
I want to origin not to change position
2.What is the issue?
When I look up origin position breaks.
What solutions have you tried so far?
I tried looking on internet for the solution
Video:
Code:
local function Shoot()
local Origin = workspace.CurrentCamera:FindFirstChild("Viewmodel" .. GunName):FindFirstChild(GunName).Barrelt.Position
local Direction = workspace.CurrentCamera:FindFirstChild("Viewmodel" .. GunName):FindFirstChild(GunName).Barrelt.CFrame.LookVector
local DirectionCF = CFrame.new(Vector3.new(), Direction)
local SpreadDir = CFrame.fromOrientation(0,0,math.random(0, math.pi * 2))
local SpreadAngle = CFrame.fromOrientation(math.rad(math.random(GunModule.MIN_SPREAD, GunModule.MAX_SPREAD)),0,0)
local FinalDirection = (DirectionCF * SpreadDir * SpreadAngle).LookVector
local caster = FastCastModule.new()
caster.Fire(caster,Origin, FinalDirection, 250, behavior)
caster.RayHit:Connect(function(cast, hit, part, material, distance)
if hit then
--print(hit.Instance)
script.Parent.Fire:FireServer(hit.Instance, GunModule.Damage)
end
end)
end