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.
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.
Closed as Not Constructive by User#19524, User#21908, and LateralLace
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?