[CODE]local MyHookFunction = function()
if LocalPlayer():KeyDown(IN_ATTACK) then
Msg("I'm attackin ya!\n")
end
end
hook.Add("Think", "My button hook", MyHookFunction)[/CODE]
when i press left click it gives me an error i want to print something in console when i press primary fire
[QUOTE][ERROR]attempt to call global 'LocalPlayer' (a nil value)
unknown - lua/includes/modules/hook.lua:84
[/QUOTE]
You are probably loading the script on server where LocalPlayer() doesn't exist
[QUOTE=Robotboy655;48150468]You are probably loading the script on server where LocalPlayer() doesn't exist[/QUOTE]
script is in garrysmod/lua folder where i have to put the script to make it work?
garrysmod/lua/autorun/client/my_very_unique_script.lua
That should work.
Isn't it better to use a KeyPress hook than a think hook to check for input?
[QUOTE=Zet0r;48156041]Isn't it better to use a KeyPress hook than a think hook to check for input?[/QUOTE]
i did this and it worked thank you otherwise it's spamming the console
Sorry, you need to Log In to post a reply to this thread.