Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Following NPC and secret message door?

REWORDED= I guess no one understood what i was getting at.

I am wanting to know how i would script a door that would open if a specific word was said in game chat, any idea on how to do that?

I am also wondering how you would script a npc to follow you when you turned around, like morgennes NPCs. (Check her game out) Im very curious, if you have any info on how i would formulate the script tell me. i am NOT asking for you to MAKE me a script. Obviously. I want to learn to DO IT MYSELF. If i can learn how to do it i wont be here much longer, thank you for your time.

8 comments

1

Not a request site!

0

Not requesting. I have no idea how to script it, so i am asking how i would do it.

0

You ARE requesting. You’re asking for someone to make the code for you.

0

Uhm? no? Im asking if anyone knows how to do it, as in HELP me make it.

0

Also whats your issue. is it cause im a noob? I came to this website to help me script what i needed. Not to be annoyed.

0

Well, help would be you have ALREADY attempted it, but it doesn’t work.

0

Ive been trying for a while now. I just can get it right, which is why i have signed up for this sight. I would'nt be here if there was a tutorial.

0

You need to attempt it on your own then post what script you have tried. Then you can ask for help. Not before. We will not spoon feed you the answer. This is a scripting helpers website. Not a we write the code for you website. We will take what you have tried and help you with it. Please try to post better questions in the future.

1 answer

For the first one you do something as simple as:

--LocalScript

local ply = game.Players.LocalPlayer
local key = ""
local door = game.Workspace.Door

ply.Chatted:connect(function(msg,rcp)	--message, recipient
	if msg == key and door.CanCollide then
		door.CanCollide = false	--Not needed if your door relies on a hinge, also make sure the door is anchored if not
	end
end)

Don't know who or what that is so I'm gonna assume from your description that it's a chase on sight npc:

--Localscript again
local ply = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera	--Player's current camera
local npc = game.Workspace.Npc
local runService = game:GetService("RunService")	--Better than while loop imo

local function isLooking()
	local val = npc:FindFirstChild("Target").Value
	if not val or val and not val.Parent then
		local pos = cam:WorldToScreenPoint(npc.PrimaryPart.Position)	--Gets a points position on the screen
		local maxDistance = 100 --Change to whatever works for you
		local distance = (npc.PrimaryPart.Position-ply.Character.PrimaryPart.Position).magnitude	--Gets distance between two parts

		if distance <= maxDistance and pos.Z > -1 then	-- -1 means its behind the camera
			npc:FindFirstChild("Target").Value = ply.Character
		end
	end
end
runService:BindToRenderStep("isLooking",0,search())

Put this in a script under the Npc:

local target = script.Parent:FindFirstChild("Target")

target.Changed:connect(function(val)
	--Code to move the character around because I'm too tired to write anymore
end)

No clue how any of this performs on a server or has any errors, but hope it helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.