-- THE ACCOMPANYING AUTOHOTKEY SCRIPT: https://www.luasnippets.com/code-snippets/twitch-2-core-commands/ _G["gbon"] = false local commands = {} -- usable numbers: 6,7,8,9,0 -- "0" followed by more numbers == marble to follow.. (bypass the normal routine) -- Don't use [0] here, saved for special.. commands[6] = {"!start",6, "StartRace"}-- twitch !command, num code, server command commands[7] = {"!reset",7, "ResetRace"} commands[8] = {"!next",8,"FollowNextPlayer"} _G["twitchcommand"] = "" -- build string to call function function _startTwitchCommand() _G["twitchcommand"] = "" -- clear the old !command end function _endTwitchComand() -- execute !command -- numbers exception (to follow target #player) i.e. 012 (0 flag, 12 num to follow) --print( _G["twitchcommand"] ) if(_G["twitchcommand"]:sub(1,1) == "0")then --print( _G["twitchcommand"]:sub( 2 ) ) -- the rest of the number -- number MUST be between 1-100 if( tonumber(_G["twitchcommand"]:sub( 2 )) > 0 and tonumber(_G["twitchcommand"]:sub( 2 )) < 101 )then print("!".._G["twitchcommand"]:sub( 2 ).." (from Twitch)") Events.BroadcastToServer("FollowTargetPlayer", tonumber(_G["twitchcommand"]:sub( 2 )) ) else --print("Bad number") end else -- normal !commands print(commands[tonumber(_G["twitchcommand"])][1].." (from Twitch)") Events.BroadcastToServer(commands[tonumber(_G["twitchcommand"])][3]) end end function _buildCommand(ss) _G["twitchcommand"] = _G["twitchcommand"]..ss end function OnBindingPressed(player, binding) -- keys are being pressed! -- KEYS TO USE For Twitch Commands: _+67890 F9 F10 if(binding == "ability_extra_58")then -- F9 _startTwitchCommand() end if(binding == "ability_extra_59")then -- F10 _endTwitchComand() end if(binding == "ability_extra_1")then -- 1 _buildCommand("1") end if(binding == "ability_extra_2")then -- 2 _buildCommand("2") end if(binding == "ability_extra_3")then -- 3 _buildCommand("3") end if(binding == "ability_extra_4")then -- 4 _buildCommand("4") end if(binding == "ability_extra_5")then -- 5 _buildCommand("5") end if(binding == "ability_extra_6")then -- 6 _buildCommand("6") end if(binding == "ability_extra_7")then -- 7 _buildCommand("7") end if(binding == "ability_extra_8")then -- 8 _buildCommand("8") end if(binding == "ability_extra_9")then -- 9 _buildCommand("9") end if(binding == "ability_extra_0")then -- 0 _buildCommand("0") end if(binding == "ability_2")then -- E (startRace) Events.BroadcastToServer("StartRace", Game.GetLocalPlayer()) end if(binding == "ability_extra_29")then -- P (portal to Lobby) Events.BroadcastToServer("ReturnToLobby", Game.GetLocalPlayer()) end if(binding == "ability_extra_33")then -- F (fly mode) Events.BroadcastToServer("FlyMode", Game.GetLocalPlayer()) end if(binding == "ability_extra_23")then -- R (reset race) Events.BroadcastToServer("ResetRace", Game.GetLocalPlayer()) end if(binding == "ability_extra_44")then -- N (follow another player) Events.BroadcastToServer("FollowNextPlayer", Game.GetLocalPlayer()) end end Game.playerJoinedEvent:Connect(function(player) player.bindingPressedEvent:Connect(OnBindingPressed) end)