How do I make the NPC's interactive?

I have been wondering for the past couple of days how to create a story game/mode like games like Pokémon brick bronze (of course I will not be using any copyright content) and some other games.

For example how do the NPC interact with players, how when NPC enters a new stage it stays there
Or boss battles.
Multiple examples but I can’t quite get my head around how they do it.

Other examples are games like camping.
When it has a storyline and the player has to follow along with it.

I have figured out a little bit on how to make interactive NPC’s that’s all.
I am not amazing at scripting.

Thanks for reading!

Please do a search on roblox dialog box that will show you a way to learn more about story writing.

1 Like

You’d need to have the GUI with a textlabel to display the text, after you make that, create a localscript in StarterGUI to detect if player is near any NPC using magnitude.
Ex:

local p = game:GetService(“Players”).LocalPlayer
local npc = workspace.NPCs.NPCName
local gui = script.Parent.DialogGUI

p.CharacterAdded:Connect(function(char)
if char:FindFirstChild(“Humanoid”) and char.Humanoid.Health > 0 and char:FindFirstChild(“Torso”) then
if (char.Torso.Position-npc:FindFirstChild(“Torso”).Position).magnitude > 5 then
gui.Enabled = true
else
gui.Enabled = false
end
end
end)

To make the text you’d need to make a table with the dialogs and if you want the typewriter effect you’d need to use this simple script

for i = 1, #text do
gui.TextLabel.Text = string.sub(text, i)
wait(0.25)
end

You would obviously need to define what’s text and change the variables on what you want

Thank you for your help.
This really helped me. I’m not asking for any script but do you know how to make NPC’s go to different areas and not come back.

You can use magnitude or make a Region3 hitbox and detect if player is in there and if they’re not, you make it stop moving.

If you want to specifically move them to a specific place and stay there, Humanoid:MoveTo(Vector3.new(x,y,z))

1 Like

Thank you again for all your help.

Np, mark with the solution icon if a reply helps you btw.