Skip to main content

Chat Controlled Missile

This project will demonstrate using a Microphone to launch a missile using Switch, and a TriggerSwitch to arm the warhead. It also contains code to detect if the player chatting is on the whitelist, and will only launch if the message contains a specified prefix.

Missile

Special configurations:

  • Microcontroller: StartOnSpawn is true
-- see http://arvidsilverlock.github.io/Pilot.lua-Luau-LSP/modules/players
local players = require("players")

local microphone = assert(Network:GetPart("Microphone"), "no microphone connected")
local triggerswitch = assert(Network:GetPart("TriggerSwitch"), "no trigger switch connected")
local switch = assert(Network:GetPart("Switch"), "no switch connected")
local gyro = assert(Network:GetPart("Gyro"), "no gyro connected")

local WHITELIST = {
-- replace with your username (case sensitive)...
["xXnoob_slayer227Xx"] = true,
}

local PREFIX = "!"

local function missile(target)
-- give power to the thruster
switch.SwitchValue = true

-- allow trigger signals from the touchsensor to detonate the energybomb
triggerswitch.SwitchValue = true

gyro.Seek = target
end

microphone.Chatted:Connect(function(player_id, message)
-- make sure that this message was sent from
-- a whitelisted player by converting player_id into username,
-- then checking against the whitelist
local player = players:GetUsername(player_id)
if not WHITELIST[player] then
return
end

-- process message, making sure that it starts with the prefix
-- and if it does, we can launch the missile
if message:sub(1, #PREFIX) ~= PREFIX then
return
end

-- strip out prefix from message
local target = message:sub(#PREFIX + 1)

-- nuke em
missile(target)
end)

Model code:

{
"m": null,
"t": "buffer",
"zbase64": "KLUv/WDeDL0rAMpCKA5I8JTUAczhYXG0PgcuTZ+By/DjxBm4Gts/pWHRlgojUu4IyN0o7UbAj4oPza5oBPiFeCgftQqAp9eTrYoTL4g4i7O1nRLptjsF2wDaAL0AKRTqpDQCgDJA2kQcaRP9KJss+et9MbcIKEDAZADIJAbBJBJ9QCUlplFM1MVevK0U6+5+xuUVZzYBpC4ACNRtAkPSn+7OZiYFy4uDBQkODpwAwDDBpEKgoE5KI1Fo624SqLvBzBPcukPc1nVzoM/W3Ruou9TdMlb0xkZIgm+JrB9FfJxOp1h3w3aQRpL05OjujsV0d6vgOALr8e7uEN1BhMhwvlisg3jo7r5R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