Yeah, I’ve been thinking about making my own and watched quite a few tutorials about it - i’m just concerned about lag. Ideally visuals (the arc motion) should be handled on the client, but I’m not sure on how to sync the damage dealer on the server, with the animations on the client.
The bullet has a delay making the shots not go where my mouse is no matter the distance, its not the speed.
I’m having some problems with the Fastcast, when the player teleports, the gun’s Raycast completely glitch, plus i’m using the example gun for test, i’m using HumanoidRootPart.Position to teleport the player, i already tried to use Tween but no sucess.
I am also having this issue. I’ve added the viewmodel to the mouse’s ignore list so I can’t be clicking on my viewmodel.
Also I used the hit detection from your example gun. (No edits)
I hear people rendering bullets on the client, but how do you do that?
I don’t even have an idea where to start with it.
In my experience, you either deal with the delay or you bite the bullet and just trust the client isn’t lying about where it’s aiming. Pretty much every FPS game is like this for good reasons.
I decided to go with a bounce back system, effectively double delay for overseas clients and you alike but far less noticeable by regional clients. The client sends to the server to fire, the server then fires to all clients. Double delay for visualising but at least the clients know exactly where the server is shooting.
you are most likely handling bullets on the server, Server latency does this, try handling your bullets on the client
I went through this whole thread but could not find what I am doing wrong.
I am trying to add the player to the UserData and this part works:
function Fire(player, direction)
...
local simBullet = Caster:Fire(FirePointObject.WorldPosition, direction, modifiedBulletSpeed, CastBehavior)
print("firing player.Name: " .. player.Name)
simBullet.UserData.player = player
...
but then in the OnRayHit function UserData is just nil
function OnRayHit(cast, raycastResult, segmentVelocity, cosmeticBulletObject)
...
local player = cast.UserData.player
print("player.Name who fired: " .. player.Name)
...
The error is clear:
attempt to index nil with 'player' - Server
Why is this? What am I doing wrong?
This same way of using the UserData seems to work for others above.
I can also get the UserData to work in OnRayUpdated, but not in OnRayHit. ???
Thanks in advance for your help!
edit:
I can also read from the UserData in OnRayTerminated but not in OnRayHit , but the documentation says:
RBXScriptSignal CastTerminating(ActiveCast casterThatFired)
This event fires while a ray is terminating (so after RayHit has fired, when applicable, but before all of the data in the ActiveCast is disposed of. It is still safe to access cast information in this event handler.)
Is this a bug then?
@Xan_TheDragon , should the UserData be always avaliable in OnRayHit?
Hey there - it has been almost two years. I assume the possibility of having homing projectiles won’t be available anytime soon? lol
Thank you for the amazing module nonetheless :))
Howdy, loving this module, however i am running into some issues with the pierce function, i am not 100% if im doing this right and recommendations on how to improve it would be appreciated (i’m fairly new to coding)
the defeated armor variable is true for sure, when it should be and the print “pierced armor” is happening however the bullet stops on impact regardless of how many times i shoot it
(everything else works fine)
if needed i can show more code
thanks! (:
https://gyazo.com/e288b10c8e52455bbfe289a01cca7d2b
local function Pierce(cast, result, velocity)
---checking if the armor defeated variable is correct
print("armor defeated?",defeatedarmor)
local Pierce_able = false
if result and result.Instance then
if result.Instance:GetAttribute("penable") then
Pierce_able = true
--everything else works
print("penned:",result)
else
if result.Instance:GetAttribute("HP") then
local varhit = result.Instance
local sound = Instance.new("Sound")
sound.Parent = result.Instance
sound.PlayOnRemove = true
sound.RollOffMaxDistance = 100
sound.RollOffMinDistance = 10
sound.Volume = 1
fleshimpact(sound)
Pierce_able = true
varhit:SetAttribute("HP", varhit:GetAttribute("HP") - sharp, blunt)
else
if result.Instance:GetAttribute("armorhp") then
if defeatedarmor == true then
Pierce_able = true
--code messes up here, when the defeated armor variable is true the code runs but the bullet stops and doesn't pierce
print("pierced armor!")
defeatedarmor = false
else
Pierce_able = false
end
return Pierce_able
end
end
end
end
end
@Xan_TheDragon
I have put logs into the functions of the Server script and I am sure there is a bug.
Looks like the OnRayTerminated runs before the OnRayHit and so the cast.UserData becomes nil in OnRayHit after that.
The documentation says it should be otherwise:
https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster/
Could somebody check this to confirm the bug or shed some light on what I might be doing wrong?
edit:
Sadly I am not making any progress.
I think this is quote clear that the OnRayTerminated happens before the OnRayHit so that is why the UserData is nil there.
Is there a fix or workaround for this?
18:55:14.734 firing owner.Name from Fire: purbanics - Server - Server:224
18:55:16.784 cast.UserData.Hits from CanRayPierce: 1 - Server - Server:161
18:55:18.917 cast.UserData.Hits from CanRayPierce: 2 - Server - Server:161
18:55:21.067 cast.UserData.Hits from CanRayPierce: 3 - Server - Server:161
18:55:23.217 cast.UserData.Hits from CanRayPierce: 4 - Server - Server:161
18:55:23.217 cast.UserData.owner.Name who fired from OnRayTerminated: purbanics - Server - Server:505
18:55:23.284 trying to do --local owner = cast.UserData.owner-- in OnRayHit - Server - Server:272
18:55:23.284 Workspace.FastCastGunSajat.Server:273: attempt to index nil with 'owner' - Server - Server:273
18:55:23.284 Stack Begin - Studio
18:55:23.284 Script 'Workspace.FastCastGunSajat.Server', Line 273 - function OnRayHit - Studio - Server:273
18:55:23.284 Script 'ServerScriptService.FastCastRedux.Signal', Line 64 - Studio - Signal:64
18:55:23.284 Stack End - Studio
figured out the issue, had the “local Pierce_able = false” in the wrong area
@Xan_TheDragon Please help!
Bug: OnRayTerminated function runs before the OnRayHit so the UserData is nil by the time you would want to use it when the bullet finally hits.
Can be reproduced easily by using the Example Gun:
https://create.roblox.com/marketplace/asset/4453914752/FastCast-Redux-Example-Gun
by adding 1 line to the Server script into the OnRayHit function to print the UserData.
It should not be nil there!
function OnRayHit(cast, raycastResult, segmentVelocity, cosmeticBulletObject)
...
print("OnRayHit")
print(cast.UserData)
end
And the result is:
19:02:42.754 OnRayHit - Server - Server:223
19:02:42.754 nil - Server - Server:224
Thanks in advance for any help!
edit:
SOLUTION - the cast.UserData is not NIL in case you use it right at the beginning of the OnRayHit function.
Hey! I’m trying tro make a throwing shuriken with this module, but projectile seems to be fired a couple studs away from the handle (even though it is using Handle.Position); it works perfectly (even deals damage) but it is invisible until 10-15 studs away from character. How can I fix this?
Video: https://gyazo.com/22a2188e174e46a11a0e98db5b7ddcfe
Thank you for reading, I’d really appreciate your help!
I know you’re probably clicking on this thinking “OH FINALLY A SOLUTION” hoping that I wasn’t going to just say “use the API” eti- cough cough.
I’m having the exact same issue and no matter what I do I can’t find any solution. Really sorry, and if anyone wants to help me and him we would greatly appreciate it.
Oh yeah, and don’t go asking eti for a solution because he will void you, and you’ll have to join one of his stupid furry discords in order to message him.
Really sorry.
This is possible. Refer to Making a combat game with ranged weapons? FastCast may be the module for you! - #870 by iamyourlordbowdown
Thank you so much! I found another way, but I will try yours too
do you plan on fixing the issue?
I was wondering: does FastCast allow you to shoot in curves? (example: like shooting the projectile upwards, and with a curve to mouse.hit)
(I don’t mean the Acceleration variable)