• attempt to index local 'input' (a nil value)
    4 replies, posted
So... i'm using this script to simulate a Toggle for my players. local antispam = false local time = 5 hook.Add("Think", "myconvar_switch", function() if input.IsKeyDown (92) and antispam == false then local ply = LocalPlayer() if(ply:GetInfo("gs_thirdperson") == "0") then antispam = true ply:ConCommand("createdconvar 1") timer.Simple(time, function() antispam = false end) end if(ply:GetInfo("createdconvar") == "1") then antispam = true ply:ConCommand("createdconvar 0") timer.Simple(time, function() antispam = false end) end end end) IT WORKS! but my console is getting full of " attempt to index local 'input' (a nil value) " also, make's my VCMOD npcs vanish (i'll not open a ticket with Freeman, because it's not his responsability) Why i'm with this? how to fix? I'm EXTREMELY NEW to gmodlua
i suggest looking at this https://wiki.garrysmod.com/page/GM/KeyPress
At the beginning of your code(Above your hook etc), Try adding: local input = 0 Not sure if its gonna work but its worth a try.
You're running the code in serverside, that's why it prints an error since input is for the localplayer, and that's clientside Put your code in lua/autorun/client
but i'm actually using this I'll try client-side autorun first, thank you! Let me test!
Sorry, you need to Log In to post a reply to this thread.