Okay so I'm Making a Ray Casting Gun. The problem I have is that I want to make a Recoil Effect on the Gun. Using math.random and Arithmetics I tried making it with this but i did not get me the results i wanted
local Vector3 = Instance.new("Vector3Value")
local x = mouse.Hit.p.X
local y = mouse.Hit.p.Y
local z = mouse.Hit.p.Z
while true do
wait()
Vector3.Value.X = x
Vector3.Value.Y = y
Vector3.Value.Z = z
end
Vector3.Value.X = Vector3.Value.X + math.random(1,0.5)
Vector3.Value.Y = Vector3.Value.Y + math.random(1,0.5)
Vector3.Value.Z= Vector3.Value.Z + math.random(1,0.5)
--^ the offset i'm talking about. It gets called each time i fire the gun.
local x1,y1,z1 = Vector3.Value.X,Vector3.Value.Y,Vector3.Value.Y,Vector3.Value.Z
local ray = Ray.new(tool.Part.CFrame.p, (Vector3.Value - tool.Part.CFrame.p).unit * 300)
-- ^ mouse.Hit.p originally goes here
Is there another way to do this? Am i Doing this wrong? Or this is just impossible?

1 comment
Any output?