Jump to content

need help coding


Recommended Posts

local function plyerdeath(isnt)

local owner = inst.follower.leader

    if owner:HasTag("playerghost") then
    inst.components.health:DoDelta(-400) 
   end
end 

i don't understand why this doesn't work , the point of this is that when the leader dies then they all die like maxwell's puppets if you have any insight that could help your welcome to share

Link to comment
Share on other sites

Well, this is all wrong

local function plyerdeath(isnt)

but I'm guessing that's just typos.

The best thing you can do here, is simply print what the state is, so you can see if your function is called at all, whether the follower still has a leader at this point, and whether that leader is a ghost or not. I would also check the leader's health-component to see what the current health is. The latter might be a better metric than checking for the ghost-tag, who knows? It depends on the exact time this function is called. IIRC there is some discrepancy between when the player died, becomes a ghost, and when his health is reset to maximum. I can't quite remember.

Just use print-statements to print out what you want to know, and you can look at your logs afterwards to see what happened.

print("currenthealth: "..owner.components.health.current)
print("follower has leader: "..(inst.components.follower.leader ~= nil))

Things like that. Just remember to check if the components are there before trying to print from them, and if they aren't, print that the component isn't there, so you know what is going on.

NOTE: Please use the <> button when putting code in your posts.

Edited by Ultroman
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...