ENT:Touch Limit

Hello all, I am trying to make it so my money printer can only interact with another entity once for example a silencer
Here is how i have set it out:


-- This is inside the silencer's init function
self.i_silence = true

-- This is the printer's Touch function
function ENT:Touch(ent)
	if ent.i_silence then
		self:StopSound("printer_noise_loop")
		ent:Remove()
	end
end

I am wondering how i could go about making it so they can only interact once to prevent player’s wasting money
Any help us appreciated :slight_smile:

Add a variable to the printer that once touched, it can’t be touched again by that entity and have the effect trigger.

Okay, i’ll give it a try. thanks for the reply :stuck_out_tongue:

add a flag such as self.Silenced = true there, then use that as a condition for future sounds.

edit
lol second

ah i mis-read

Okay, thanks for your replies i managed to get it done :stuck_out_tongue:
Just in case anyone wondered how, this is what i did:


-- Printer's init function
self.IsSilenced = false

-- Then my touch function looks like this
function ENT:Touch(ent)
	if not self.IsSilenced then
		if ent.i_silence then
			self:StopSound("printer_noise_loop")
			self.IsSilenced = true
			ent:Remove()
		end
	end
end