Need help clarifying some things

I have recently been working on a projectile gun for a game. However, I have ran into some complications, which I wish to hopefully solve through this post.

  1. Moving the bullet: Most tutorials say to use something like BodyVelocity, and I found that it was deprecated. I checked Instance.Velocity, and that was also deprecated. What is the current method for moving objects?

  2. How does one handle actual collisions of projectiles and objects? My main issue is that I do not wish for an exploiter to simply change the script in the bullets, if they can even do that. Do I use BasePart.Touched for collisions, or is there a better method?

  3. Lastly, how do I make it seem smooth? I hear that you should use FireAllClients to handle physics, but I cannot understand how that works. Won’t that cause an event that causes damage to fire multiple times because of how many clients there would be?

1 Like

I personally would just move the bullet each frame and rayCast to detect if it hit anything. The only way to 100% prevent hacking the bullet logic is by making the bullets server sided (using scripts instead of localScripts).

1 Like

You can solve all of the problems with a pre-made module named fast cast made for projectile weapons. The module helps you handle the moving (even accounting for realistic physics) and collisions.

1 Like

Wouldn’t this not work well for larger projectiles?

Is there a guide I can use that helps understand what modules are? Is this like a module script? Or is this like some sort of global function that can be called in any script?

  1. You can use a LinearVelocity to move the bullet
  2. Physics bullets can always be exploited. So i would say just set the Networkownern of the part to nil and use something like Zoneplus to detect collision idk
  3. See point 2
1 Like

i dont see why not. if you have a wide projectile just use another raycast.

link to tutorial:

The tutorial explains everything well and all you have to call the global function inside the module. I don’t suggest writing your own projectile script as the fast cast already used some advanced methods to remove lag and server/client problems for you.

1 Like

I ended up following this tutorial, only thing I can’t figure out is how to use CastTerminating to remove the bullet afterwards. There doesn’t appear to be any Bullet parameter passed to that function, atleast on the FastCast website
https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster/

You can remove the bullet by calling bullet:Destroy() after the hit event. You can also add bullet parameters by using the user data array.


	local playerdata = {
		PlayerName = player.Name,
		BulletDamage = damage,
	}
	
	caster:Fire(origin, direction, 1500, castBehavior, playerdata)

The problem is that sometimes the bullet may not actually hit something, so I can’t really on using the Hit event to destroy the bullet. Also, I solved the damage problem by putting an IntValue in the bullet itself :smiley:

If you can’t use the hit event, you can reference the bullet directly. When the fast cast runs, the module will create a folder called “BulletFolder” in the workspace. If you want to destroy all bullets, you can call :ClearAllChildren() on the folder. If you want the bullet to destroy after a certain time, you can use the ChildAdded event to track the bullet and use the debris service like debris:AddItem(bullet,time)

Well, this just shows I still have a lot of learning left to do! Thanks for that, didn’t know ChildAdded was even a thing!

1 Like

np, I hope your game turns out great!