Playing a sound doesn't work.


AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()
	self:SetModel("models/weapons/w_package.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self:SetUseType(SIMPLE_USE)

	self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
	local phys = self:GetPhysicsObject()

	phys:Wake()
	hook.Add("PlayerDisconnected", self, self.onPlayerDisconnected)
end


function ENT:Use(ply)
	ply:SetArmor( 100 )
	surface.PlaySound( "physics/wood/wood_strain2.wav" )
	self:Remove()
end


At the bottom, surface.PlaySound() doesn’t play the sound. It works if I take the sound path and play it in console.

surface.Playsound() only works on the client.
Check at the bottom

Try:


self:EmitSound("physics/wood/wood_strain2.wav")

Yes, but when I use my entity it doesn’t play the sound for me.

That didn’t make any sound, and then the self:Remove() didn’t work, it didn’t remove itself.

is the function even being called?

also you’re missing ENT:SpawnFunction so that could be the problem

It works just as I want it to except for the sound. I just edited “food” from DarkRP, to an entity that changes playermodel, but I also want to play that sound so it sounds like equipping it(best one I could find).

try
[lua]
self:EmitSound(“physics/wood/wood_strain2.wav”,100,100)
[/lua]

It actually worked without the 100, 100, I’m not sure what I did wrong the first time I tried.
Thank you!