• am i doing this right?
    5 replies, posted
Okay So I'm trying to block players from using the material tool on certain props. Does this look like it would work? hook.Add("BlockMaterial", "DarkRP_blockoneway", function GM:CanTool( ply, tr, tool ) if tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "models/props_building_details/Storefront_Template001a_Bars.mdl" then return false end end
Close, but hook.Add("CanTool", "DarkRP_blockoneway", function( ply, tr, tool ) if tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetModel() == "models/props_building_details/Storefront_Template001a_Bars.mdl" then return false end end The CanTool, or hook event name goes as a first argument, but without the metatable/gm table in front of it, so GM:DoSomething becomes DoSomething. now next we define and assign a new function to the event that's gonna happen. And at the end you got entities class, but you were looking for a model. Good try if it was a first try tho, already more effort put in than most of the people that come here. Also, next time put it in code brackets, helps readability
Please use a descriptive title next time too
Thanks for the helpful response man! Yes, This was my first time trying hooks so I was a little confused haha. I used the code you did but it doesn't seem to work? I stuck in the autorun/server folder but I am still able to use the tool on the prop? Any idea why would be helpful, thanks!
No idea, add a print to the beginning of the file to see if it's being even executed, you're sure it's in lua/autorun/server?
Sorry, you need to Log In to post a reply to this thread.