Gmod lua player material (first script)
So, I made my first simple lua script for Garry's Mod that sets my player material. But other players can't see it and I was wondering if there was a way to fix it to make it visible to other players. Thanks!
Btw, here's the code--
Show code
O = "\nLua Script (first one)\n\n"
N = "\n"
local Ply = LocalPlayer()
MsgC(Color(25,152,255),O)
chat.AddText(Color(70,255,30),"Type !Mat to set your material, and type !Clr to reset it.")
hook.Add( "OnPlayerChat", "HelloCommand", function( ply, strText )
if ( strText == "!Mat" ) then
Ply:SetMaterial("models/debug/debugwhite")
chat.AddText(Color(255,10,10),"[ALRT]: ",Color(25,152,255),"Material applied.")
return true
end
if (strText == "!Clr") then
Ply:SetMaterial("")
chat.AddText(Color(255,10,10),"[ALRT]: ",Color(25,152,255),"Material Reset.")
return true
end
end )
MsgC(Color(255,255,255),"hi ",Ply:Name(),"\n","Ping: ",Ply:Ping(),N,"SteamID: ",Ply:SteamID(),N)
If this is serious, running it clientside won't affect your material for other clients, this would have to be ran on the server for other clients to be able to see it which would require access to the server itself. I recommend you learn Lua and basic clientside/serverside concepts before continuing to make "simple lua script"'s.
You'd need to use a net message to broadcast it to all the clients connected to the server.
Been over a week since last update/bump after answers, assuming solved.
/Closed.