Hey man, I was curious so I tried out your test gun today. I just made a new place in Roblox and your gun keeps inserting itself into my game when I press “Play” or “Play here”. I have no idea how this happens but it’s pretty annoying.
Here is a video. As you can see I do not have the gun anywhere in my game. It also generates an insane amount of errors, which isn’t caused my my script since it only has 1 clickdetector function in it.
Like many other users I’m having trouble with the player dying, bullets not being removed, and freezing in place.
I’m using the example gun. I have FastCastRedux and PartCache script hierarchies in ReplicatedStorage. When the Server script of the gun starts, I have it parent itself into ServerScriptService, which does let the bullets continue rendering after the player dies.
This only partially resolves the issue, since now every time a player respawns with the gun, another copy of the server script is moved into ServerScriptService, which means I now need a method of detecting when all bullets of a caster have been terminated so I can remove the old server script. Is there a solution to this? What is the preferred method?
I feel like for a module that is designed to make guns that kill characters, making it work properly after a character dies is not easily done, or at least is not considered what should be default behavior, or am I missing something?
I’ve read through many of the replies in regards to this issue, and have taken the steps suggested (moving the server script out of the Tool itself) but as explained above that only partially solves the issue, since now you have to figure out how to dispose of the old server scripts which are still rendering bullet objects from characters who have died.
Do I need to tag each gun and have the same server script check for new guns and create casters for them rather than have a server script for each gun?
At this point it seems like it would be much easier to store each cast on the server script and destroy all existing bullets when the character dies rather than try to let them keep rendering.
edit: the solution I’ve come up with for now is creating a table on the gun server script called ‘allCasts’. In the Fire() function I add the simBullet object to the allCasts table. I create a Tool:Unequipped() connection that loops through the casts and calls cast:Terminate() on them. Not the ideal solution but seems to work well for unequipped the tool and character death.
Hey, a question in regards to multiple weapon visuals. I have one Caster and one Behavior on the client handling all bullet visuals every time a request comes in, just changing the Acceleration and other Bullet Specifics on the spot before firing. Is this an acceptable way of handling it?
I want to use the casterRayPierced event to change the FilterDescendantsInstances array when it bounces off of an object. To be more specific, in order to do this lightsaber deflect thing, once the bullet pierces the saber, the character model of the person who blocks it is now inserted into the FilterDescendantsInstances. I put that code into the casterRayPierced event, but when I get casterRayHit back, the filterDescendantsInstances are the original ones from the start.
I know there is weird behavior with the RaycastParams object. Can you guys give me some insight on how to edit RaycastParams of the ActiveCast through the pierced event?
EDIT:
I have a workaround, but it’s pretty bad:
In your canRayPierceCallback, instead of returning true, instead, always return false, and in the cases that it does return true, call caster:Fire(…) again with the new parameters, whilst also having a new RaycastParams object there. Seems to work fine for me so, but I would really like to know how to edit RaycastParams in the rayPierced callback. It seems like re-firing the caster isn’t how this module is intended to work.
EDIT 2: I found the solution! apparently querying RaycastParams points to a copy, not the actual one, so instead, you have to make a separate table, then set the params new property to that. You also must put this in CanRayPierce, not RayPierced.
I moved the server script into ServerScriptService, adjusted it a bit, so all “guns” works off that single script. Not sure if it’s a good idea but at least the bullets don’t stay in the air anymore.
Would it be possible to visualize the projectile’s trajectory with beams when using this module? Say, something like this. A use case example would be if you want aiming to be easier for users in your game.
I’m having issues with armour pieces blocking the bullets from damaging a target. Is there a way to whitelist them so that bullets can go through them?
Also, is there a way to maybe have each bullet act as a straight beam rather than individual bolts?
If I had to guess I’d say that the “GunFirePoint” isn’t exactly where it should be, since bullets should start at the position of the that fire point attachment.
@Xan_TheDragon Is there any plan to implement the bullet penetration system based on the part’s thickness?
Since I’ve tried using this method, for example, BasePart.Size.X/Y/Z but it doesn’t work accurately since if the projectile is coming from the x-axis but the code check for the z-axis part size and I don’t know how to check what axis of where the projectile is coming from.
I’ve tried using this method but I can’t get it to work using your FastCast system.
I’ve implemented bullet trails in my game. The issue is that they don’t replicate very well from the server to the client. Do you think it would be a good idea for the server to simulate the cast as well as send the cast data to the client so the client can create the cast locally and simulate the trail.
I’m sorry, i replied the wrong person, but when i do this, it give me an error ‘‘Cannot statically invoke method ‘ReturnPart’ - It is an instance method. Call it on an instance of this class created via PartCache.new’’
I am using this in my game to power dodgeballs. It is creating a lot of network issues. Players lagging and jumping around etc…
I used the example raygun provided, changed it to be a ball shape, and to only shoot one ball every 1.5 seconds. Any ideas on why its causing such significant network jitter when there are only ever 4-5 balls bouncing around at any given time?
Hey, I’ve been using your module and its fantastic. However I have little criticism on the documentation. I was curious is Caster:Fire() returned the activeCast however your docs don’t go over if it does. I had to read the module’s code instead. It would be fantastic if you made this small adjustment to the documentation so people don’t have to go through the confusion I had to. Aside from that your documentation is fantastic I really appreciate the effort put into this module
Sorry I am late. Of the replies I have read that pose new questions, here’s some answers:
The method given on that thread seems like it would work. You basically just need to do a raycast in your pierce callback. The origin of the ray should be exactly how the thread describes it: some distance in the same direction of the incoming ray, and then the direction of the new ray is the opposite of the bullet’s direction.
This will have issues if you have a very large part and bullet drop, because this method can’t figure out where a curve will start and end within a part, doing that will be quite complicated…
The error message says exactly what you need to do:
local cache = PartCache.new()
local part = cache:GetPart()
not
local part = PartCache:GetPart()
A static invocation means that you called the method on the actual module itself rather than one of the module’s custom objects that is, again, created via PartCache.new().
That’s in the method signature.
The format all methods follow is ReturnType Name(parameters...) - if a function returns nothing, its return type is void in lieu of typical programming terms. In this case, it means the method’s name is Fire, and it returns an ActiveCast instance.
hello, I was reviewing the module and found a programming error. Basically maximum distance doesn’t work on rays that don’t have physics, since they only produce raycast per update.
Don’t you understand me?, I’ll explain: the distance is checked when the trajectory is updated, which means that you will have to wait for the trajectory to update to check the distance.
This would not be affected on ranged weapons, but on handheld weapons; you have to wait for the raycast to update and the distance would never be correct.
I suggest checking the distance in one heartbeat from the last point - the origin.
This module is amazing but I have one issue.
How can I get the player thats firing the caster?
Unlike the example code I dont use a script / remote event inside of the tool.
I have one remote event that every player uses that connects to a script inside of serverscriptservice so multiple people use the same caster.
How do I get the player that fired the caster? For my OnHit event I need to get the player dealing damage before dealing damage to another player so I can do some checks.
You can get the active cast object and stuff it in the UserData folder like so, from the active cast documentation.
local activeCast = currentEntityFastCastHandler:Fire(origin, direction)
local bulletOwner = world.Get(entity, PlayerComponent)
activeCast.UserData.Owner = bulletOwner
activeCast.UserData.BulletID = bulletID --bulletID system
ProjectileService.ReplicateProjectileClientToServer:Fire(origin, direction, attachment, bulletID)
to identify the owner
local function rayHit(activeCast, result: RaycastResult, segmentVelocity, bullet)
local instanceHit: BasePart = result.Instance
local owner = activeCast.UserData.Owner
--do stuff
end
local castComponent = entityFastCastHandler.fastcast
local replicationRayHitSignal = castComponent.RayHit:Connect(rayHit)