Jump to content

Recommended Posts

Hi.

I successfully created new creatures with the help of someone nice last time.

These creatures are summoned when my character reads a book.

When summoned, they were good at following my character.

But when I shut down the game and log back on, they don't move.

Can you tell me how to get followers to follow my character even after I leave the server and come back in?

I'm sorry I always seem to get help.

Thank you for reading.

Since I don't have your scripts, so this is what I would do.

You may look into how Chester and Abigail follow players in general.

For Chester, he will keep following as long as the tag exists.

local function OnStartFollowing(inst)
    inst:AddTag("companion")
end

local function fn()
...
    inst:AddComponent("follower")
    inst:ListenForEvent("startfollowing", OnStartFollowing)
...
end

For Abigail, she is linked to the player 'permanently'.

local function linktoplayer(inst, player)
    inst.persists = false
    inst._playerlink = player
    player.abigail = inst
    player.components.leader:AddFollower(inst)
    for k, v in pairs(player.abigail_flowers) do
        k:Refresh()
    end
    player:ListenForEvent("onremove", unlink, inst)
end

local function fn()
...
	inst.LinkToPlayer = linktoplayer
...
end

 

Edited by mentalistpro
  • Like 1
  • Thanks 1
7 hours ago, mentalistpro said:

Since I don't have your scripts, so this is what I would do.

You may look into how Chester and Abigail follow players in general.

For Chester, he will keep following as long as the tag exists.


local function OnStartFollowing(inst)
    inst:AddTag("companion")
end

local function fn()
...
    inst:AddComponent("follower")
    inst:ListenForEvent("startfollowing", OnStartFollowing)
...
end

For Abigail, she is linked to the player 'permanently'.


local function linktoplayer(inst, player)
    inst.persists = false
    inst._playerlink = player
    player.abigail = inst
    player.components.leader:AddFollower(inst)
    for k, v in pairs(player.abigail_flowers) do
        k:Refresh()
    end
    player:ListenForEvent("onremove", unlink, inst)
end

local function fn()
...
	inst.LinkToPlayer = linktoplayer
...
end

 

Thank you for reply.

I wrote the script based on the template someone posted and the code of Abigail.

aidenorbbrain.lua 

aidenorb.lua -This is the follower I made

magictools.lua - This is the book that summons the follower.

The same problem occurred when I tried to use the code in the template because I thought the code I modified might be wrong.

I'm sorry to bother you.

Thank you.

5 hours ago, Yakuzashi said:

I am not sure, but this might help.

Thank you but I've already used this tutorial.

I don't know why this problem happened, but I came up with a temporary solution.

The problem I have is that when I close the server and come back in, my followers don't follow me.

So I would rather have the followers automatically disappear from the world when I ended the server.

(For example, if I turn off the game, the followers automatically die.)

Is there any way to do this?

I am afraid it's far beyond my capabilities, but I am pretty sure that someone on this forum will help you. Anyway I hope this will help somehow

	Line 406: self.inst:ListenForEvent("ms_playerjoined", OnPlayerJoined, TheWorld)
	Line 407: self.inst:ListenForEvent("ms_playerleft", OnPlayerLeft, TheWorld)
   

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...