Positioning question for FPS games

FPS games have a viewmodel (which the player can see) and player’s character (which everyone can see). So how would I position stuff like projectiles, mag/bullet shell drops, and other stuff so they feel smooth and look good from every player’s perspective?

I thought of firing the clients to create the objects themselves which could work but what about projectiles? If I were to do this, how would I detect when the projectile hits the target without worry of exploitation? (I’d like to use FastCast for the projectiles)

IMPORTANT: the viewmodel and the actual player arms are at different positions. I’m having trouble positioning projectiles, mag/bullet shell drops, and other stuff realistically. Well I could render the objects separately, but there is another problem look at my second paragraph.


This tutorial should help you start to make a FPS. It explains everything for the basics of how to rig a gun and use cframe just to name a few. Best of luck, John.


Have you even read what I said? The topic you sent doesn’t even contain anything about server side replication of when the player equips and uses the gun.

I have already used that topic to its fullest with my own version of server replication. But now I am stuck on the problem of positioning other objects (mag drops, bullet drops, projectiles, etc) because they are two different view points. Sadly the topic doesn’t include anything about my problem.

1 Like

I would use raycasts,and a IgnoreList to detect when the projectiles hit
Just print everything the bullets hit from the ignoreList

Just makes the Cameras CFrame to Viewmodels head CFrame

local humanoid = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid");

local viewModel = game.ReplicatedStorage:WaitForChild("viewModel"):Clone();

local function onDied()
	viewModel.Parent = nil;

local function onUpdate(dt)
	viewModel.Head.CFrame = camera.CFrame;


Projectiles can be made with raycasts,for a more advanced way you can use this(CFrame Projectiles)

Event.OnClientEvent:Connect(function(Client, StartPos, EndPos)
	local Spell = Instance.new("Part")
	Spell.Size = Vector3.new(1, 1, 1)
	Spell.Anchored = true
	Spell.CFrame = CFrame.new(StartPos + Vector3.new(0, 3, 0), EndPos)
	Spell.Parent = Client.Character
	for i = 1,100 do
	local ray = Ray.new(Spell.CFrame.p, (Spell.CFrame.p + Spell.CFrame.LookVector * 1 - Spell.CFrame.p).unit * 2)
	local part, position = workspace:FindPartOnRay(ray, Client.Character, false, true)
	if part then part:Destroy() Spell:Destroy() return else end
	Spell.Position = Spell.Position + Spell.CFrame.LookVector * 1

Mag/Shell Drops
Mag is just animations,Via blender or roblox.For roblox the mag must be its on model

Shell Drops
Create the shell, position it where you want it, and add a bodyvelocity,Use DebrisService to clean up everything.

Also for detecting it you could do this

    local CameraRay = Ray.new()
    local HitPart, HitPosition = ws:FindPartOnRayWithIgnoreList(CameraRay, Ignore)

    print(HitPart, HitPosition) 

I suppose you know how to make a ray and how to fill out the () by Ray.new

Mark as soltuion

Hes trying to find out how to detect each object the bullet hits

I already know how to detect bullet hit (also i’d like to use FastCast for it). Thats not my question. I know how to make mag/shell drops thats not my question either. Perhaps im just not being clear. My question is, how would I position them so they -

1 Like

Position right where the shells come out of,use BodyVelocity to apply force/push them
you can use other ones such as BodyForce,BodyThrus

Use Debris to clean them up

have a module, that replicates the raycasts shooting out of the weapon, and fire that across all clients within a radius,https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

Mark as soltuion

there is my problem. I know how to do everything else, but the viewmodel and the actual player arms are at different positions with different angles. so do you understand my problem now?

1 Like

so right before the player shoots add a wait(.1) and duplicate the shell,place it where the shell is suppose to come out of,Like where shell casings come out of.Then use BodyVeloicitys to push them out further.

Mark as soltuion
As I dont want this to be still replied to when it has been solved

Sorry but that is not my solution or anywhere near the answer to my problem. I made an edit to the topic. Look at the last paragraph


Why would he mark it as solution when you didn’t solve anything?

As for the OP’s ACTUAL question, placing the bullet right in front of the viewmodel’s barrel should be fine, depending on whether the player turning up or down replicates. It shouldn’t be too far from what everyone else sees. If it is, you could always go through the work of programming another clientsided muzzle flash for everyone else to mask where the bullet actually is.

1 Like

just send the start and final position over to the server, and then that will fire all clients,send the desired velocity over the server, and then back to the players involved.

Next time look up stuff before you post about it

I was thinking there might be a better way than trying to do that, but I guess there is no better way. I’m not going to mark that as solution yet because there still might be someone who knows a better way to do it.

1 Like

Well, there’s really not, other than bending the arms for everyone else to try to match up to what the
viewmodel looks like.

1 Like

The way I’d do this, I’d render all the animations on the client-side for every player and send only what data I need (Look angle, Position, HumanoidState for stuff like crouching, etc), this should help minimize network lag

Then as for firing guns and positioning projectiles:

  • Player shoots, send relevant data to server to calculate the shot(FireStartingPosition, FireAngle), while rendering the shot for the player
  • Server verifies the shot, sends relevant data to every other player, so they could render the same shot

This should allow every player’s character and projectiles to match up, since the latency involved is one-way

  • Character animation (Player -> Server -> Other players)
  • Projectile creation (Player -> Server -> Other players)

You could get more advanced, with time syncing and predictive projectile tracking if you really want to, but in my opinion that’s only good for server validation and using it for animations could create visible “jumps”

  • Player shoots at time = 0, position 0
  • Server receives the shot at time = 10, position = 10
  • Other players render the shot at time = 20, but already at position = 20 to account for the latency

This is technically more “accurate” in terms of rendering where shots end up, but if you’re looking at the characters firing the shots it might look jumpy because the shots are rendered where they should be at the time they are received by clients (already travelling on air), rather than from the actual start position (coming from the shooter’s gun).

Here’s where the problem comes, if I send firestartingposition, it should be in viewmodel’s shootpoint. (Since I am sending it, I will have to also make some sort of anti-exploit). If the firestartingposition is viewmodel’s shootpoint, it will be different than what the server/other players actually sees (since the 2 positions are different. So this wouldn’t match up. The angles of the trajectory would be different if I were to calculate a new angle based on the player character shootpoint to try to match it up. But I could just have them not match up since there is no other way. Also do you know what anti-exploit I could have since player’s are sending the starting position?

Hmmm… then you’d probably want to go about this backwards. You’d need to calculate the end of the bullet trajectory, then render shots from the player character’s gun to that end position… which does require you to GetFiringAngleFromEndOfBulletTrajectory(EndPos, StartPos, GunType, etc)

Do note that doing this, the shot would be fired from a sliiightly different position than from where it actually started, depending on how far the character’s gun is from the viewmodel, though I highly doubt there’s a significant difference

For anti-exploit measures, verify if the shot is valid by:

  • Comparing the FiringStartPos to the Character’s position (too far = invalid, etc)
  • Calculating the trajectory and validating the hit (simulate the shot with zero time between intervals, check if it aligns with the first check, etc)