Good morning everyone. I am using this code to shoot a part
Effect.PrimaryPart.BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
Effect.PrimaryPart.BodyVelocity.Velocity = CFrame.new(plr.Character.RightHand.Position, mouse.p).lookVector * settings.Speed.Value
It is supposed to shoot the part from the player to the mouse position. The problem is this-
When I use this code in a separate project on its own, it works fine
When I use it in my main project, it sometimes work, sometimes it shoots in the direction the player is facing, and sometimes it shoots in a random direction, most often the opposite way the player is facing.
There are no scripts manipulating the camera position or movement in the main project.
Any idea what I am doing wrong?
1 Like
Code seems ok, but check out if the mouse hits anything unusual like VFX particles or parts.
If so then you will need to blacklist it like the post below.
Hello, yesterday I made an energy beam for my game which points towards the mouse position, but today I noticed this bug:
https://gyazo.com/91ccfaf2e5c83971f7238a6acb401fad
It works fine most of the times, but sometimes this happens and I’m not quite sure why. I’m not really experienced with this kind of things, and this is my first beam that goes towards the mouse instead of where the HumanoidRootPart is pointing. This is the code that changes the beam’s CFrame:
Beam.CFrame = CFrame.new(Char…
1 Like
This looks like it might be the solution. There are particles in the Effect which might be messing it up.
I looked at your solution. Where would I apply the mouse filter? Noob question, I know, but I am very new to this…
1 Like
In my solution it uses the newer raycasting so the filter is with the RaycastParams .
1 Like
Thank you. I will try to figure it out
1 Like
Forummer
(Forummer)
July 21, 2022, 3:23pm
#6
mouse.p
this is likely invalid, you probably meant mouse.Hit.p
instead.
Mouse
is internally deprecated. You can only do this in a LocalScript, and use Mouse.Hit.Position
instead.