Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/690c794b-14ac-8002-a146-ba84ec97f888
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== == <syntaxhighlight lang="lua"> -- // =========================================== -- // Real-time Crime vs Detective Game System -- // Roblox Lua Script (ServerScriptService) -- // Author: ChatGPT (GPT-5) -- // =========================================== -- CONFIGURATION ------------------------------- local CriminalGoalTime = 180 -- seconds for the Criminal to achieve goal local DetectiveTurnDuration = 20 -- seconds per investigation turn local TotalDetectiveTurns = 9 local CivilianKillPenalty = 10 -- seconds reduced from Detective's timer per civilian death local GameActive = true -- GAME STATE ----------------------------------- local Criminal = { Name = "CriminalPlayer", Target = "VIP", KilledCivilians = 0, IsCaught = false } local Detective = { Name = "DetectivePlayer", TimeRemaining = CriminalGoalTime } -- SERVICES ------------------------------------- local RunService = game:GetService("RunService") -- FUNCTIONS ------------------------------------ -- End the game and declare winner local function EndGame(winner) GameActive = false print("=====================================") print(" GAME OVER! Winner: " .. winner) print("=====================================") end -- When a civilian is killed local function OnCivilianKilled(victim, isTarget) if not GameActive then return end if isTarget then print("[!] Criminal eliminated the target successfully.") else print("[X] Criminal killed a non-target civilian! Instant defeat.") EndGame("Detective") end end -- When a civilian dies (even target) — affects Detective’s time local function OnCivilianDeathEffect() if not GameActive then return end Detective.TimeRemaining = math.max(0, Detective.TimeRemaining - CivilianKillPenalty) print("[⚠] Detective’s time reduced by " .. CivilianKillPenalty .. " seconds! Remaining: " .. Detective.TimeRemaining) if Detective.TimeRemaining <= 0 then EndGame("Criminal (Detective ran out of time)") end end -- DETECTIVE AI Behavior ------------------------ local function DetectiveAI() while GameActive do task.wait(DetectiveTurnDuration) local turnNumber = math.floor((CriminalGoalTime - Detective.TimeRemaining) / DetectiveTurnDuration) + 1 print("🔍 Detective Turn #" .. turnNumber .. " begins.") -- Chance to find evidence local foundClue = math.random() < 0.4 if foundClue then print("🧾 Detective found new evidence!") else print("... No useful evidence found this turn.") end end end -- CRIMINAL AI Behavior ------------------------- local function CriminalAI() local elapsed = 0 while GameActive and elapsed < CriminalGoalTime do task.wait(1) elapsed += 1 -- Random events simulation if elapsed == 60 then print("[EVENT] Criminal attacked a civilian (non-target).") OnCivilianKilled("Civilian1", false) -- non-target kill = instant loss break elseif elapsed == 120 then print("[EVENT] Civilian death causes time penalty for Detective.") OnCivilianDeathEffect() end if elapsed % DetectiveTurnDuration == 0 then print("⌛ Time: " .. elapsed .. "s / " .. CriminalGoalTime .. "s total.") end end if GameActive then EndGame("Criminal (escaped successfully)") end end -- GAME START ----------------------------------- print("=====================================") print("🔫 Game Start: Criminal vs Detective") print("Criminal must complete their goal in " .. CriminalGoalTime .. " seconds.") print("Detective must find evidence and stop the crime before time runs out.") print("=====================================") -- Run both AI simulations in parallel task.spawn(DetectiveAI) task.spawn(CriminalAI) </syntaxhighlight>
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)