Jump to content

adding THIS code to a prefab

Recommended Posts

Hello! I need help adding this code to a custom item for my character.

the code is as follows (thanks DarkXero)

local pos = inst:GetPosition()
local ents = TheSim:FindEntities(pos.x, pos.y, pos.z, 10, {"playerghost"})
for i, v in ipairs(ents) do

My problem is i don't know where to add it in the item. The item is a pan flute, but its a copy so it doesnt interfere with the original panflute. I want to remove the sleeping effect and replace it with this one.

Link to comment
Share on other sites

If you're using the panflute as a template, you don't need to call TheSim:FindEntities, that's already taken care of by the instrument component. Instead, replace your HearPanFlute with this function:

local function HearPanFlute(inst, musician, instrument)
	if (inst:HasTag("playerghost")) then

Untested, but it should work.

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

  • Create New...