Hey my doods,
i have no idea what i'm doing,but i was trying to make a .wav file play when someone types certain words in chat ,but i need some help to figure this out
function chatCommand( ply, text, public )
if (string.sub(text, 1, 4) "Scream")then
sound.Play("murder/Scream.wav"()
Muder is just a folder inside "sound"
You forgot the == in between string.sub and the string
Thank you,but how would it be then ? (i'm pretty new to this)
function chatCommand( ply, text, public )
if (string.sub ==(text) "scream")then
surface.playsound("murder/Scream.wav"()
Im on my phone so I cant test it but first off I'll tell you that I'm assuming you are using this function to put inside a hook because without it would literally do nothing.
The return "" will make it so it prints nothing in the chat when the person uses the command.
local function chatCommand(ply, text, public)
if(string.lower(string.sub(text, 1, 5)) == "scream") then
surface.PlaySound("murder/Scream.wav")
return ""
end
end
Thank you a lot!
haha sorry for disturbing though
really appreciate it
.
don't forget to use GM:OnPlayerChat, not GM:PlayerSay. GM:PlayerSay is serverside only and you can't use the surface library serverside.
Sorry, you need to Log In to post a reply to this thread.