Introducing LocalCast: Easy Weapon Creation and Server-Side Projectile Casting Precision!

Hey Roblox Developers!

I’m localModuled, and I’m excited to introduce you to LocalCast.
LocalCast is an easy-to-use module that enables smooth bullet projectiles and correct server-side hitboxes.

  • How does LocalCast ensure accurate server-side hitboxes, and how does it handle this?
    When using server-side hitboxes, you might encounter issues where the client and server don’t sync correctly. For example, your client might show that you hit an opponent, but the server might not register it. This discrepancy happens because players are constantly moving, and the server struggles to keep up with these changes due to latency.

Example:

LocalCast solves this problem with a custom ‘Recorder’ system that I developed. This system records every frame for up to the last 2.5 seconds, ensuring precise hitbox detection and minimizing inconsistencies between the client and server.

Here’s how it works: When a client sends a projectile request to the server, it also includes the client’s timestamp. The server receives this timestamp and simulates the game state from that moment in the past. By recreating the hitboxes and simulating the frames from that point forward, the server aligns its view with what the client saw. This approach effectively resolves discrepancies and ensures that the hitboxes perceived by the client match what the server detects.
So, no more desynchronized projectiles! :laughing:

Using LocalCast is incredibly straight forward. It’s possibly one of the simplest things you’ll encounter. All you need to do is require the module and call LocalCast.new().

When you create a new LocalCast instance, here’s what you can access on either the server or client:

local LocalCastModule = require(ReplicatedStorage.LocalCast)

--If you are using on Client for example.
local LocalCast = LocalCastModule.new("IdExampleWeapons")

--If you are using on Server for example.
local LocalCast = LocalCastModule.new("IdExampleWeapons", function(player, origin, direction, projectileData, tag)
	--[[ Check here for the server authorize. Example: checking ammo
		local AmmoAmount = 2
		if AmmoAmount > 0 then
			return true
		end
	]]
	
	return true --or false
end)

LocalCast.OnHit:Connect(OnHit) -- instance, position, projectileData
LocalCast.OnDistanceReached:Connect(OnDistanceReached) -- position, projectileData
LocalCast.OnDistanceChanged:Connect(OnDistanceChanged) -- position, distanceTraveled, projectileData
LocalCast.OnDestroy:Connect(OnDestroy) -- position, projectileData
  • OnHit: Triggered when the projectile hits something, providing the instance, position, and projectile data.
  • OnDistanceReached: Triggered when the projectile reaches its ‘MaximumDistance’ without hitting anything.
  • OnDistanceChanged: Fires every frame when the projectile’s position changes.
  • OnDestroy: Triggered when the LocalCast instance is destroyed.

To create a projectile, simply call the LocalCast:Create command. Here’s an example:

LocalCast:Create(Origin, Direction, {
	Velocity = 500,
	BulletModel = ExampleBulletModelPath,

--[[ Optional parameters:
    RaycastParam = RaycastParams,
	Gravity = Vector3.new(0, -98.1, 0),
	MaxDistance = 2500,
	MetaData = {
	  -- Any custom data to send with the projectile. For example:
	  Damage = 20, -- Accessed via projectileData.MetaData.Damage
	},
]]
})

LocalCast handles the client-side simulation of projectile models automatically. When you create a projectile on the client, a request is sent to the server. If the server approves the request, it will broadcast it to other clients, allowing them to simulate the projectile. This means you don’t need to manually set up RemoteEvents or other networking; simply call Create from the client.

Here is an example roblox place LocalCast Example Place - Roblox
To get LocalCast on library LocalCast

The module is still under development and open to any suggestions, so feel free to ask questions or share your ideas!

LocalCast used in Blade Blitz! game.

Version 1.0.2

30 Likes

Can’t wait to make projects with LocalCast :star_struck:

2 Likes

Looks nice. I will use it when I need LocalCast.

2 Likes

Very cool! I will giver this a try sometime

1 Like

Very useful! Very professional

1 Like

What’s the difference between this and something like SecureCast?

1 Like

I don’t have much information about SecureCast but I can tell you LocalCast focused to create an easy-to-use server sided projectiles, let me know if you have any suggestions! :pray:

1 Like

Ladies and gentlemen, you’re looking at fair competitive game sauce here!

1 Like

Will you ever make an API somewhere that describes all the functions and what they do? Also, is it possible to have the server be a midldeman and validate all the times the client tries to shoot, and have the server modify values or block them if they are exploited?

1 Like

Hey, an API page & github page will be available soon. Also there is server side check. It is looking for authorize, developer can use here for any check for projectile.

Let me know if you have any questions :pray:

okay but what does that actually do and when is it actually used? Like when are the parameters seen or defined, how do i define those parameters, when is the function called and used, etc.

1 Like

That is the function on server when client send request to server, calls before creating server side projectile and sending all clients to create projectile except who sent. So first that function is checking and looking for authorize. If your function returns true, you gave authorize. If your function returns false, you didn’t give authorize so nothing happens.

Hello,

I am checking out your test place in studio.

  1. since this has server side shizzle, will this help with cheaters etc ?

  2. is there a way of making the grenade bounce, instead of sticking to where it hits?

  1. can there be time delays before an explosion… like the grenade is thrown and hits something then explodes after 5 seconds?

  2. can a projectile have multiple parts that cause damage , like a frag grenade that explodes and then has smaller projectiles that move out from the explosion and also cause damage? Like each smaller one does say 10 damage…

  3. can a shot gun with multiple spread pattern be done?

  4. is the speed of a bullet or projectile customizable?

  5. can it be set that some weapons do not damage a team member?

  6. can it be set where some weapons do also damage a team member ?

  7. can a heal projectile be done where team members can get healed via a projectile?

  8. can a projectile be launched and then not do damage until a player touches it… like a land mine projectile ?

  9. will you be adding any other weapons to the test place?

  10. After starting to look at the code, if the weapons have local scripts and configurable variables, does that mean the client can change how the weapon behaves on the server (and other clients) such as the Velocity

also the fire point, so they could extend that out and shoot through a wall?

or the gravity on the grenade?
Why not have these defined on the server that the weapons reference?

  1. How can VFX be added such as particles on a hit where the sound origin is the position of the hit?

  2. Same with sounds on hit …

  3. server side checks, how can delays before next use be added to the weapons so you cannot spam them?

  4. is there a way of having an weapon option where it will stick to the player as they move away? Like a sticky bomb? (or the knife, it stays in the air)

  5. is there a way where the bullet decal can stick to a player too? when they move away the decal is in the air…

  6. How can I get the AK to do damage? I changed the script to use the damage you had commented out, but it still does not damage…

Thanks

1 Like

Hey, firstly thank you!
1- Server side hitboxes safer than client sided, for more safety you need to move something to the server side, like velocity and origin point. Just take the direction from client.
2- LocalCast doesn’t support bounce yet, but I’m thinking to add it.
3- Yep, you can do it! You can get the hit position with :OnHit on server side. Put a 5 seconds delay and create a hitbox and detect players when it exploded.
4- Yep! You can create a grenade shrapnel that each gives 10 damage. Listen for the :OnHit on server side and get the hit position and call the :Create to create projectiles to the 360° random directions.
5- Yep, you can create a shotgun with LocalCast that sends a few bullet to the random directions. To do this, just give random directions and call a few times :Create.
6- Speed of the bullet or bullet model is customizable in every single projectile.
7- Yep, you can set it, put a check if the players is in same team to give no damage before the damage code line.
8- Yep, same. You can put a check if the players in same team, and give damage.
9- Yep, you can create heal projectile.
10- No, projectile works like a bullet. But to create landmine you can use hitboxes.
11- Maybe, if i update the version and add new features, I can add some weapons to showcase them.
12- In the current test place, we are getting velocity from the client but it is changable, you can get it from the server, it is up to you.
13- You can create VFXs: Listen :OnHit from the client and it gives you the hit position and by getting hit position you can emit VFXs or play any sound effect that you want.
14- 13.
15:

Here is the server authorize part. You can create a server sided debounce system and check if player can shoot or not here. Give return true, false, nil.

false, nil → not authorized
true → authorized

You can check anything on server side from here. Debounces, enough ammo etc.

16- There is no option but it is possible to do it with LocalCast, basically you can get hit instance.
17- Yep, 16.
18- You should add your damage script to the :OnHit part on server side. OnHit is the server hitbox. It calls when a projectile hits to an instance. It gives you ‘instance, position, projectileData’.

Let me know if you have any questions or suggestions. Thank you!