Hello! The title might be a bit confusing so let me explain.
I’m trying to make a ball shoot towards where your mouse is pointing, however using Mouse.Hit.p makes it go wherever I put my mouse, so if I would point my mouse up at the sky it just flies away. Is there a way to make it go towards where I’m pointing my mouse but only a bit, say 50 studs.
I think you’re supposed to use Unit, since both are Vector3 types and I don’t think you can get the direction using Magnitude. Also, Mouse.Position should go first before Gun.Position, or else you get the inverted direction
Shouldn’t the gun position be first since that’s where the ball is going to shot from? Also, I’ve used magnitude for the past 3 years and it has never betrayed me, there might be better methods out there, but magnitude works greatly for me.
You need to add the vector to the humanoidrootpart’s position because that vector is only going to be 50 studs away from the origin, facing the mouse’s position in the world. Also, this isn’t really limiting it, as this code will always just make the ball go 50 studs in the direction of your mouse from the humanoidrootpart, which is unintended. You can try this:
local vec = mouse - humrp.Position
local target = humrp.Position + vec.Unit * math.min(vec.Magnitude, 50)
local tween = TweenService:Create(tornado, TweenInfo.new(2), {Position = target})
tween:Play()