How to Make a Survival Game on Roblox — Crafting, Building & PvE Tutorial

How to Make a Survival Game on Roblox

Popular Roblox Survival Games

Core Systems

Hunger & Thirst

-- ServerScriptService/SurvivalStats.lua

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)

-- Create survival stats

player:SetAttribute("Hunger", 100)

player:SetAttribute("Thirst", 100)

player:SetAttribute("Health", 100)

-- Drain stats over time

spawn(function()

while player.Parent do

wait(10) -- Every 10 seconds

local hunger = player:GetAttribute("Hunger")

local thirst = player:GetAttribute("Thirst")

player:SetAttribute("Hunger", math.max(0, hunger - 2))

player:SetAttribute("Thirst", math.max(0, thirst - 3))

-- Take damage if starving/dehydrated

if hunger <= 0 or thirst <= 0 then

local char = player.Character

if char then

char.Humanoid:TakeDamage(5)

end

end

end

end)

end)

Crafting System

local RECIPES = {

WoodenSword = { Wood = 5, Stone = 2 },

StonePickaxe = { Wood = 3, Stone = 5 },

Campfire = { Wood = 10, Stone = 3 },

WoodenShelter = { Wood = 20, Rope = 5 },

}

local function craft(player, itemName)

local recipe = RECIPES[itemName]

if not recipe then return false end

local inventory = getPlayerInventory(player)

-- Check if player has all materials

for material, amount in pairs(recipe) do

if (inventory[material] or 0) < amount then

return false

end

end

-- Consume materials

for material, amount in pairs(recipe) do

inventory[material] = inventory[material] - amount

end

-- Give crafted item

addToInventory(player, itemName, 1)

return true

end

Day/Night Cycle

-- ServerScriptService/DayNightCycle.lua

local Lighting = game:GetService("Lighting")

local DAY_LENGTH = 720 -- 12 minutes per full cycle

while true do

for minute = 0, 1440 do -- 24 hours in minutes

Lighting.ClockTime = minute / 60

wait(DAY_LENGTH / 1440)

end

end

Skip the Hard Part — Use Roblox Factory

Roblox Factory generates your entire game — 13+ Lua scripts, art, marketing — in one click for $29/month.

👉 Try Roblox Factory Now →


All articles · Roblox Factory · Game & Anime ARMY