I have a problem which i know can be solved but im just missing something in my code.
My code does (Mouse.hit.position - Pistol.Handle.Position) / duration
the problem is when i point to the sky it goes kinda out of bounds and bugs out. I still want to be able to point it to the sky but for it to have a max range and it apples force there instead of the skybox.
I guess one way would be checking if it’s greater than a certain amount.
BasePart:GetPropertyChangedSignal("AssemblyLinearVelocity"):Connect(function()
if BasePart.AssemblyLinearVelocity.Magnitude > yourMaxAmount then --You might want to check individual elements of the Vector3, mangitude was just an example
warn("limits for the AssemblyLinearVelocity is needed")
end
end)
if that's for calculating direction it'll be off because that will point to the target's CFrame. You might wanna try `Camera:ScreenPointToRay()` instead and then using something like `workspace:Raycast()` with `RaycastParams`
He is looking for the maximum force, not the maximum velocity. Note that force is defined as mass times acceleration (in cases where the mass is constant), meaning it’s the mass of the block multiplied by the rate of change of its velocity.
This topic seems like you are trying to find a workaround to an issue with mouse.Hit. While we could calculate the acceleration and therefore the force with some maths calculations, it may be better to solve the problem from it’s root and fix the mouse.Hit issue. I’m not sure why mouse.Hit may be nil, but it may be a better option to create a ray and cast from that, or something like ApplyImpulse might do the job.