How to make an FPS game in Roblox Studio
First-person camera, a gun that fires on click, headshots, ammo and reload — with the hit check on the server so exploiters can't one-tap the whole lobby.
Updated November 16, 202611 min read
A first-person shooter lives or dies on how shooting feels. The player must see their shot react instantly, while the server decides what was actually hit — otherwise exploiters can hit anyone from anywhere. The standard pattern is simple: the client sends where the camera aimed, the server checks the shot is possible and casts the ray itself.
The core loop
Every FPS game comes down to one loop that players repeat. Build this first, in grey blocks:
- Spawn with a weapon
- Find enemies and shoot
- Get kills, die, respawn
- Unlock or pick better loadouts
Systems you need
First-person camera
Set StarterPlayer → CameraMode to LockFirstPerson in Properties. The camera stays in the head and the mouse is locked to the center of the screen.
Gun tool
A Tool in StarterPack. Turn off RequiresHandle to start with no model, or add a Part named Handle (later, a gun mesh) so it shows in the player's hand.
Server raycast
workspace:Raycast from the player's camera toward where they aimed, cast on the server with RaycastParams that exclude the shooter's own character.
Fire rate and ammo
Kept on the server per player: time of the last shot, bullets left, reloading or not. The client keeps a copy only to show it.
Damage and kills
Humanoid:TakeDamage on the server, more for hits on the Head, and a Kills stat in leaderstats when a shot finishes someone.
Crosshair and HUD
A small Frame in the middle of a ScreenGui and an ammo label that reads the Ammo attribute the server sets on the player.
Build order
- 1
Map and spawns
A small arena first: cover to hide behind, two or three SpawnLocations far apart. Big maps feel empty with few players.
- 2
Camera
Select StarterPlayer and set
CameraModetoLockFirstPerson. Press Play to check you look through the character's eyes. - 3
The gun tool
Insert a Tool named
Rifleinto StarterPack and turn offRequiresHandle. Put the LocalScript from below inside it. - 4
Server script
Paste the server Script into ServerScriptService. It creates the
FireandReloadRemoteEvents, the Kills stat and the shot checks. - 5
Test with two players
Test → Clients and Servers → 2 players. Shoot each other: body shots take 25, headshots 50, and the Kills stat goes up.
- 6
Feel
Add a gun model, a muzzle flash, a shot sound and a hit marker on the client. These make the biggest difference to how the game feels and change nothing on the server.
The key script: Server-checked shooting, headshots, ammo and reload
Where it goes: ServerScriptService > Guns (Script) + StarterPack > Rifle (Tool) > GunClient (LocalScript).
- StarterPlayer →
CameraMode=LockFirstPerson. - A Tool named
Riflein StarterPack withRequiresHandleturned off. - The code below is two scripts — split it at the dashed line. The first is a Script in ServerScriptService, the second a LocalScript inside the
Rifletool.
-- ServerScriptService > Guns (Script)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GUN = {
toolName = "Rifle",
damage = 25,
headshotMultiplier = 2,
range = 300,
fireDelay = 0.12, -- seconds between shots
magazine = 30,
reloadTime = 2,
}
local fireEvent = Instance.new("RemoteEvent")
fireEvent.Name = "Fire"
fireEvent.Parent = ReplicatedStorage
local reloadEvent = Instance.new("RemoteEvent")
reloadEvent.Name = "Reload"
reloadEvent.Parent = ReplicatedStorage
local states = {} -- [player] = { ammo, lastShot, reloading }
local function resetAmmo(player)
states[player] = { ammo = GUN.magazine, lastShot = 0, reloading = false }
player:SetAttribute("Ammo", GUN.magazine)
end
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = leaderstats
resetAmmo(player)
player.CharacterAdded:Connect(function()
resetAmmo(player)
end)
end)
Players.PlayerRemoving:Connect(function(player)
states[player] = nil
end)
fireEvent.OnServerEvent:Connect(function(player, origin, direction)
-- Never trust what the client sends: check every value.
if typeof(origin) ~= "Vector3" or typeof(direction) ~= "Vector3" then
return
end
local length = direction.Magnitude
if not (length > 0.5 and length < 1.5) then -- also rejects NaN
return
end
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local head = character and character:FindFirstChild("Head")
local state = states[player]
if not (humanoid and head and state) or humanoid.Health <= 0 then
return
end
if not character:FindFirstChild(GUN.toolName) then
return -- an equipped tool sits inside the character
end
-- The shot has to start at the player's head (the first-person camera).
if not ((origin - head.Position).Magnitude <= 8) then
return
end
local now = os.clock()
if state.reloading or state.ammo <= 0 or now - state.lastShot < GUN.fireDelay * 0.8 then
return -- 0.8 leaves room for network jitter
end
state.lastShot = now
state.ammo -= 1
player:SetAttribute("Ammo", state.ammo)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = { character }
local result = workspace:Raycast(origin, direction.Unit * GUN.range, params)
if not result then
return
end
local model = result.Instance:FindFirstAncestorOfClass("Model")
local target = model and model:FindFirstChildOfClass("Humanoid")
if not target or target.Health <= 0 then
return
end
local victim = Players:GetPlayerFromCharacter(model)
if victim and player.Team and victim.Team == player.Team then
return -- no friendly fire when you use Teams
end
local damage = GUN.damage
if result.Instance.Name == "Head" then
damage *= GUN.headshotMultiplier
end
target:TakeDamage(damage)
if target.Health <= 0 and victim then
player.leaderstats.Kills.Value += 1
end
end)
reloadEvent.OnServerEvent:Connect(function(player)
local state = states[player]
if not state or state.reloading or state.ammo == GUN.magazine then
return
end
state.reloading = true
task.wait(GUN.reloadTime)
if states[player] == state then -- not respawned meanwhile
state.ammo = GUN.magazine
state.reloading = false
player:SetAttribute("Ammo", state.ammo)
end
end)
--------------------------------------------------------------------
-- StarterPack > Rifle (Tool) > GunClient (LocalScript)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local tool = script.Parent
local player = Players.LocalPlayer
local fireEvent = ReplicatedStorage:WaitForChild("Fire")
local reloadEvent = ReplicatedStorage:WaitForChild("Reload")
local FIRE_DELAY = 0.12 -- same as fireDelay on the server
local equipped = false
local holding = false
local function shoot()
if (player:GetAttribute("Ammo") or 0) <= 0 then
reloadEvent:FireServer()
return
end
local camera = workspace.CurrentCamera
local size = camera.ViewportSize
local ray = camera:ViewportPointToRay(size.X / 2, size.Y / 2)
fireEvent:FireServer(ray.Origin, ray.Direction.Unit)
-- Play the shot sound and muzzle flash here, so it feels instant.
end
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
holding = false
end)
tool.Activated:Connect(function()
if holding then
return
end
holding = true
while holding and equipped do -- hold to keep firing
shoot()
task.wait(FIRE_DELAY)
end
end)
tool.Deactivated:Connect(function()
holding = false
end)
UserInputService.InputBegan:Connect(function(input, processed)
if not processed and equipped and input.KeyCode == Enum.KeyCode.R then
reloadEvent:FireServer()
end
end)How it works
- The client only sends where the camera looked. The server checks the shot starts at the player's head, that the gun is equipped, the fire rate and the ammo, then casts the ray itself — so an exploiter can't say “I hit that player” from across the map.
- Hits on the
Headpart do double damage. Hits on a hat count as body shots, because the hat is its own part. - Ammo lives on the server and is shown to the client through the
Ammoattribute: read it withplayer:GetAttributeChangedSignal("Ammo")in your HUD. - Add more guns by putting their numbers in a table keyed by tool name instead of the single
GUNtable.
How FPS games make Robux
- Weapon skins and kill effects — cosmetic, so free players can still win.
- A VIP game pass with a custom name color, a private-server discount or an extra loadout slot.
- Developer products for a currency used on skins and crates. Check the Roblox rules on paid random items before adding crates.
- Avoid selling stronger guns. Pay-to-win kills shooters fast, because losing to a paid weapon feels unfair.
You receive 70% of what players spend on game passes and developer products; Roblox keeps 30%.
Common mistakes
Damage dealt from a LocalScript
It works in a solo test and lets exploiters kill anyone. Damage, kills and ammo all belong on the server.
The client reports the hit
A RemoteEvent like Hit(targetPlayer) lets exploiters hit whoever they want. Send the aim and let the server raycast.
No fire-rate check on the server
The client's wait between shots is only for show — exploiters can fire the RemoteEvent as fast as they like. Count time on the server.
Forgetting to exclude the shooter
Without RaycastParams excluding your own character, the ray hits your own head first and the gun seems to do nothing.
Testing alone
Shooting only feels right with someone to shoot. Use Test → Clients and Servers with 2–3 players from the first day.
FAQ
How do you make an FPS game in Roblox Studio?
Set StarterPlayer's CameraMode to LockFirstPerson, give players a gun Tool, and handle shots on the server: the client sends where the camera aimed, the server checks it and raycasts. This page has both scripts.
How do I make a gun in Roblox Studio?
Insert a Tool into StarterPack, put a LocalScript inside that sends the camera's aim to a RemoteEvent when the tool is activated, and a server Script that raycasts with workspace:Raycast and calls Humanoid:TakeDamage on what it hits.
How do I make first person in Roblox Studio?
Select StarterPlayer in Explorer and set CameraMode to LockFirstPerson in Properties. To force it for one player only, set the same property on that Player from a script.
Can you make an FPS game in Roblox without scripts?
Not a working one. You can build the map without code, but shooting, damage and ammo need scripts. The scripts on this page are complete, so you can paste them and change the numbers.
Why does my Roblox gun not do damage?
Most often the ray hits your own character because it isn't excluded in RaycastParams, the damage runs in a LocalScript, or the Humanoid lookup starts from a hat instead of the character model.