missdirection is the direction of the raycast, it goes to your mouse but should be changed from the offset module but since am calling the variable right after the modules called i think the module doesn’t get enough time to change the variable and it uses the old one
–viewmodel.offset
function ViewModelFramework.Offset(Player, OriginalDirection)
local BodyVelocity = Player.Character.Torso.Velocity.magnitude
local SprayOffset = BodyVelocity * 0.7
print(SprayOffset)
print(OriginalDirection,"Original")
OriginalDirection = OriginalDirection + Vector3.new(math.random(-SprayOffset, SprayOffset), math.random(-SprayOffset,SprayOffset),0)
print(OriginalDirection, "Original, new")
end
yeah, I agree with Zombie. Why doesn’t this return the value? If you’re changing a variable from the ModuleScript, calling it from other scripts won’t do anything.
So, in the module, you have OriginalDirection, and you change it with the Vector3. However, you aren’t changing OriginalDirection in the other script. When you pass it as a parameter, you’re only passing the value, not the reference. Changing it on the module doesn’t do anything. What you should be doing is