I have a script that creates a ray from root part to mouse.Hit.p and creates on click. I used tween to move a part to the mouse position. It doesn’t fire when the mouse is targeting the sky. Ik that clicking at the sky doesn’t return a mouse position, so im stuck.
Side questions (don’t wanna have to post multiple threads):
I haven’t tried it yet, but Im unsure whether or not that the part im tweening to mouse.Hit will detect a hit from the raycast. The ray will hit something even if the part hasn’t reached that position. How would I go about synchronizing the ray and the part?
Currently using tween, but im open to more suggestions on how to move the part/projectile.
I also am aware of fastcast, but I want to try making my own scrip[t
When I make guns I do Tween the bullets. All you’d have to do is Tween whatever you are doing to the mouse by checking for the Ray, if its there or not. I believe if you are having something like:
local hit,pos = workspace:FindPartOnRay ect...
Then you could probably just use “pos” to send it to the mouse.
I was once told if there is no ray it will just go where ever the max distance you have on it.
Ik that clicking at the sky doesn’t return a mouse position, so im stuck.
It should return a position, but that position is going to be very very far away (when I tested around 10000 studs) so the bullet is just moving so fast to there you can’t see it.
You can do:
Ray.new(humanoidrootpart, mouse.Hit.p.Unit * 20)
Essentialy, what we’re doing here is making a ray that only goes 20 studs in the mouse’s direction, you can change the 20 sruds to anything. mouse.Hit.p.Unit returns the direction of the mouse, which is a unit vector (a vector of length one, these are used to describe directions). This is a vector lf length one, looking torwards the mouse, if I scale it by 20, it’s basically going 20 studs torwards the mouse.