#(clouddino) How to toggle NPC following player
116 messages · Page 1 of 1 (latest)
(clouddino) How to toggle NPC following player
Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
!guide script editor
View the guide page 'Setting Up Your Script Editor' at: https://guide.denizenscript.com/guides/first-steps/script-editor.html
I dont really plan on using this much after this small NPC for a practice range, is it possible to do without this?
the other settings in it have been working fine
It takes like 10 minutes to set up, and then you have it forever - I'd just do it real quick, as the error checking, syntax highlighting documentation, etc. are very useful
Alright ive done that, but it isnt highlighting any issues with the line that i need help with
does it do highlighting and shows colors?
yeah it does
nice that means the file extension of your script file is correct
right so what do i do now to fix the following setting
let me review it real quick
!paste
Help us help you by pasting your script to https://paste.denizenscript.com/New/Script and linking it back here.
Content of Denizen Script Paste #135754: ty!... pasted 2025/08/24 11:42:09 UTC-07:00, Paste length: 829 characters across 23 lines, Content: strafe_menu_handler: type: world events: on player clicks in strafe_menu_inventory:
so you want to make the npc follow the player, but only in a specific area and make the npc go to its spawn point if the player leaves it
right now theres settings so that players can customise how the NPC interacts with them for aim training
i just want them to be able to click something and the npc will be toggled to follow them
then a seperate thing that isnt toggleable to limit where the npc walks
entity
follow (followers:<entity>|...) (stop/target:<entity>) (lead:<#.#>) (max:<#.#>) (speed:<#.#>) (allow_wander) (no_teleport)
Causes a list of entities to follow a target.
Causes a list of entities to follow a target.
Specify the list of followers or just one. If no follower is specified, will use the linked NPC.
Specify either the target to follow, or 'stop'. If no target is specified, will use the linked player.
Use 'speed' to set the movement speed multiplier.
Use 'lead' to set how far away the follower will remain from the target (ie, it won't try to get closer than the 'lead' distance).
Use 'max' to set the maximum distance between the follower and the tar...
to make the npc follow a player
and then make a noted area (the area the npc can wander in)
yeah i think thats what im attempting to use but im a bit slow
!e entity enters/exit
Did you mean to search for entity enters|exits area?
would it be possible to make them freeroam instead?
Entity
cancelling this event will have different results depending on the cause. Teleporting the entity away 1 tick later might be safer.
<entity> enters|exits <area>
when an entity enters or exits a noted area (cuboid, ellipsoid, or polygon). On Spigot servers, only fires for players. Paper is required for other mob types.
When the entity is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<context.area> returns the area object that was entered or exited.
<context.cause> returns the cause of the event. Can be: WALK, WORLD_CHANGE, JOIN, QUIT, TELEPORT, VEHICLE.
<context.to> returns the location the entity moved to (might not be available in exit events).
<context.from> returns the location the entity moved from (when available, depending on cause).
<context.entity> returns the entity that entered/exited an area.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
and then just players can walk up and interact with them
if you want that yes,
alright thank you
!m wander
Did you mean to search for command weather?
i have the wander stuff sorted and have made it toggleable, i just need to stop them from walking out of our little practice range and into like water
!m waypoint_provider
Sets the NPC's waypoint provider (default options: linear, wander, guided).
NPCTag
ElementTag
<NPCTag.waypoint_provider> Returns the NPC's current Waypoint Provider type (default types: linear, wander, guided).
need to set it to wander ^ and then you can choose the range with the mechanisms above ^
oh cool
If the NPC's waypoint provider is set to wander (!mechanism NPCTag.waypoint_provider),
sets the current WorldGuard region that wandering is restricted to.
Provide no input to remove the region restriction.
Depenizen, WorldGuard
NPCTag
WorldGuardRegionTag
<NPCTag.worldguard_wander_region> If the NPC's waypoint provider is set to wander (<@link tag NPCT...
yeah deadass i cant understand how to use the follow tool
!info haste debug
Help us help you by pasting your script to https://paste.denizenscript.com/New/Script and linking it back here.
If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!
if you provide both I can check for errors
Content of Denizen Script Paste #135760: thank you... pasted 2025/08/24 14:18:42 UTC-07:00, Paste length: 831 characters across 24 lines, Content: strafe_menu_handler: type: world events: on player clicks in strafe_menu_inventory:
Content of Server Log Paste #135761: Denizen Debug Logs From A Minecraft Server... pasted 2025/08/24 14:19:53 UTC-07:00, Paste length: 5834 characters across 69 lines, Content: `Java Version: 21.0.7 Up-time: 7m 55s Denizen Version: Core: 1.91.0-SNAPSHOT (Build 1397), Spigot: 1.3.1-SNAPSHOT (build 7144-DEV) Script Containers: 6, Ev...
is this good?
i appreciate it a lot thank you
oh it looks the same as before
oh
i think i broke something
and then i reset it back to what it was before
since it wasnt working anyway
can you elaborate a little bit more about how your script should work
like the whole idea
be as precise as possible please
when you right click the npc it brings up a gui like this
and when you click the item it will make the NPC follow you
or toggle it
what will it do? is it guarding the player, is this a specific npc only or can every player have an npc following them
it will be a practice dummy for combat
they will be free roaming
like 5 of them
and then a player can walk up to the NPC and it will follow them if they toggle it on
until they either leave the area or if they toggle it off
okay so you don't need to do instancing npcs
i want them to have the option of it being roaming or if its following them is all
since it isnt vanilla pvp its using a seperate plugin
i do not
!guide mechanism
View the guide page 'Mechanisms And Properties' at: https://guide.denizenscript.com/guides/basics/mechanisms.html
it's fairly simple, but you need the npc object available inside the inventory
can you show me the inventory part please?
this?
yea but in script form
Content of Denizen Script Paste #135762: Edit of paste 135754: ty!... pasted 2025/08/24 14:29:49 UTC-07:00, Paste length: 533 characters across 6 lines, Content: strafe_menu_inventory: type: inventory inventory: chest size: 9
oh holy
😂
Content of Denizen Script Paste #135762: Edit of paste 135754: ty!... pasted 2025/08/24 14:29:49 UTC-07:00, Paste length: 533 characters across 6 lines, Content: strafe_menu_inventory: type: inventory inventory: chest size: 9
On line 7: This line appears to contain raw object notation. There is almost always a better way to write a line than using raw object notation. Consider the relevant object constructor tags.
On line 5: Data lines should not be quoted. You can use '<empty>' to make an empty line, or '<&dq>' to make a raw double-quote symbol, or '<&sq>' to make a raw single-quote.
On line : (Statistics) Total structural lines: 2
On line : (Statistics) Total live code lines: 1
On line : (Statistics) Total comment lines: 0
On line : (Statistics) Total blank lines: 0
you can remove each i@ there
do you have the interact script for me too
what i would do is instancing the inventory script and pass the npc data onto the relevant items
Content of Denizen Script Paste #135764: Edit of paste 135762: Edit of paste 135754: ty!... pasted 2025/08/24 14:33:23 UTC-07:00, Paste length: 1701 characters across 53 lines, Content: strafe_menu_inventory: type: inventory inventory: chest size: 9
heres just hte full thing
Content of Denizen Script Paste #135764: Edit of paste 135762: Edit of paste 135754: ty!... pasted 2025/08/24 14:33:23 UTC-07:00, Paste length: 1701 characters across 53 lines, Content: strafe_menu_inventory: type: inventory inventory: chest size: 9
On line 20: Script section is empty (add contents, or remove the section).
On line 21: Line purpose unknown, no identifier (missing a : or a -?).
On line 13: This line appears to contain raw object notation. There is almost always a better way to write a line than using raw object notation. Consider the relevant object constructor tags.
On line 28, 36, 40, 44: Inappropriate usage of the 'execute' command. Execute is for external plugin interop, and should never be used for vanilla commands. Use the relevant Denizen script command or mechanism instead.
On line 23: Stray space after end of line (possible copy/paste mixup. Enable View->Render Whitespace in VS Code).
On line 5: Data lines should not be quoted. You can use '<empty>' to make an empty line, or '<&dq>' to make a raw double-quote symbol, or '<&sq>' to make a raw single-quote.
On line : (Statistics) Total structural lines: 16
On line : (Statistics) Total live code lines: 23
On line : (Statistics) Total comment lines: 0
On line : (Statistics) Total blank lines: 6
There are 3 lines that were merged into other lines.
need to fix that ^
e.g. instead of - inventory open d:in@strafe_menu_inventory you would create that inventory dynamically e.g.
- define inventory <inventory[strafe_menu_inventory]>
- inventory flag destination:<[inventory]> slot:1 npcData:<npc>
- inventory open destination:<[inventory]>
then you can use it in the click event, e.g instead of execute as_server "npc wander --id 6" you could use execute as_server "npc wander --id <context.item.flag[npcData].id>
or use the mechanism that makes the npc wander - adjust <context.item.flag[npcData]> waypoint_provider:wander
npcData holds the NPCObject that you can use in any command that takes an NPCTag
have to go to sleep now but I hope it helps
yeah thank you so much
Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.
If not yet resolved, please reply below to tell us what you still need.
(Note that if there is no reply for a few days, this thread will eventually close itself.)
@wicked gorge