#The Follower Wont die when the player does?

1 messages · Page 1 of 1 (latest)

brazen tangle
#

so this game i have a player with an npc following you. But when the player dies, the npc following the player doesnt dissapear? is there any way to detect when the player dies then make it so if the player dies, the follower dissapears? heres a video.

#

heres the FollowerController script

#

movement

#

thats the little guy that follows me

#

and heres the

#

animate script

#

which adds the animations to the little guy

#

so he doesnt just float

#

if someone could help me that would be great

#

i used tutorials for these since im not great with coding

tawdry parrot
#

Humanoid:Dies()

#

it triggers when the player dies

ivory anvil
#

isn't it Humanoid:Died()

tawdry parrot
#

so from that you can connect a function

tawdry parrot
#

and with that function just delete the npc

brazen tangle
#

what function would delete the npc

tawdry parrot
#

stop all connection by disconnecting / setting to nil

tawdry parrot
brazen tangle
tawdry parrot
#

didnt rea the code

ivory anvil
ivory anvil
tawdry parrot
#

you should know it yourself how to remove the 'pc

brazen tangle
#

its in serverstorage so when a player spawns in, then it spawns in

tawdry parrot
#

cause it's your code

brazen tangle
#

thats why i need help T^T

#

sorry

ivory anvil
#

WAIITT

#

ELDUS VALLEY

brazen tangle
ivory anvil
brazen tangle
ivory anvil
#

same

brazen tangle
#

but its a good game

ivory anvil
#

so create a function with :Died()

#

and when its fired

#

:Destroy the model of the follower

brazen tangle
#

im getting confused

ivory anvil
#

not if

#

function

#
[Humanoid of Player Character].Died:Connect(function()
  [Model of the Follower]:Destroy()
end)

@brazen tangle

brazen tangle
#

ty <3

ivory anvil
#

Humanoid.Died isnt a if statement

brazen tangle
#

so much

ivory anvil
#

its a function

#

if statements only happen once

#

functions happen when an event happens

brazen tangle
#

where would i find the humanoid of the player character

ivory anvil
#

under the player character

brazen tangle
#

also do i need to do something else if the Follower is inside of ServerStorage

ivory anvil
#

is the follower copied into the game

#

when the player spawns

brazen tangle
#

if the player spawns, so does the follower with it

#

and itll only follow the player it spawned with

ivory anvil
#

so yes

brazen tangle
#

but if that player dies, then the follower completely stops

#

but it doesnt go away

#

its just there

ivory anvil
#

so you have to find the follower's model

#

in the game

#

and :Destroy() it

brazen tangle
#

is Humanoid.Died:Connect(function()
PlayerFollower:Destroy()
end)

#

is that good?

ivory anvil
#

yes

#

but when the player dies

brazen tangle
#

or should it work

ivory anvil
#

I mean spawns

#

the playerfollower isn't in serverstorage

#

its in workspace

brazen tangle
#

yeah

#

i want it to work for every player tho

ivory anvil
#

ok

brazen tangle
#

so how would i do that

ivory anvil
#

so put a script under the follower

#

destroys itself

#

when

#

like

#

use string.split()

#

idk how to explain this easily

brazen tangle
#

would images help

#

this script is under the playerfollower

#

which is inside of serverstorage

ivory anvil
#

ok

#

so for the destroy

#

do

#

script.Parent until it reaches the follower's model

#

remove string.split

brazen tangle
#

hm

ivory anvil
#

how deep is the script

#

inside of the follower

brazen tangle
ivory anvil
#

show me the script inside of the follower

brazen tangle
ivory anvil
#

ok

#

so you only do it once

brazen tangle
#

animate is just so the follower has animations

ivory anvil
#

put :Destroy() on the same line as script.Parent

brazen tangle
ivory anvil
#

ok

#

so get the Follower's name

#

set a variable to the Follower's Name

brazen tangle
ivory anvil
#

yeah

#

set a variable to the Follower's Name inside the script

#

and we can use string.split() to split the username from 's Follower

#

and FindFirstChild() inside workspace to get the player character

#

and find its humanoid

brazen tangle
#

sorry im a bit confused

ivory anvil
#

and detect if that died

ivory anvil
brazen tangle
#

how?

ivory anvil
#

use script.Parent to head up

#

and use .Name to get it

brazen tangle
#

something like this?

brazen tangle
#

rip rising

#

he helped me then randomly disappeared