Jump to content

Make things say something on hit


Recommended Posts

--character.lua

--anywhere above masterpostinit
local function OnAttackOther(inst, data)
	if data.target and not data.target.components.health:IsDead() and data.target.components.talker then
		data.target.components.talker:Say("Hey")
	end
end

--masterpostinit
inst:ListenForEvent("onattackother", OnAttackOther)

However, prefabs without the talker component wouldn't be able to talk

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...