TTT: Set Player´s Role

I make a script with events for the Garry´s Mod Gamemode “Trouble in Terroristtown”. One Event shall be that All Detectives on the Server change the Role to Innocent so that there are only Innocents and Traitors for the Round. After the Round Ends, Everything is normal again. How do I do that ? I couldn´t find such a command in the GMod Wiki.

But there is a lot of examples in google or workshop with TTT roles changing (and an already made events addon). You’re looking for a solution and not help?

I know that there are scripts in the internet. But the most of them change all roles and shuffle them. I need the command that change only the role of detectives to innocents.

It can be done with basic glua knowledge. If you can’t do things like this, you can’t say ‘I make a script’ and you can’t create your own event system.

function ChangeOnlyTheRoleOfDetectivesToInnocents()
   for _, ply in pairs(player.GetAll()) do
      if ply:IsDetective() then

But it’s not exactly what you need.

Thanks. Now I know how to use. And yes you are right that this is basic knowledge. But if you script for a longer time then it can happen that you forget things like that. I mean scripting Lua isn´t the only thing I do everyday.