Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do I make a npc move when I say "Hi" in chat?

Asked by 3 years ago

Example: when i type "hi" in the chat, the NPC will start walking to me.

3 answers

Log in to vote
0
Answered by 3 years ago

Scripting Helpers is not a request site! (But I’ll give you the part that detects if you say “hi” in chat)


local PlayersService = game:GetService("Players") local StringToDetect = "hi" PlayersService.PlayerAdded:Connect(function(Player) Player.Chatted:Connect(function(Message) if string.find(string.lower(Message), string.lower(StringToDetect)) then if Player.Character then -- code end end end) end)
Ad
Log in to vote
0
Answered by
0hsa 193
3 years ago
local str = "Hi"
local npc_character = PATH.TO.YOUR.NPC

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAppearanceLoaded:Wait()
    local char = player.Character
    player.Chatted:Connect(function(msg)

        if string.find(
                string.lower(msg),
                string.lower(str)
            ) then

            local npc_hum =
                npc_character:FindFirstChildOfClass("Humanoid")

            if not npc_hum then
                return
            end

            npc_hum:MoveTo(char:GetPrimaryPartCFrame().Position)
        end

    end)
end)

haven't tested

0
local npc_character = game.Workspace.The Npc’s name . NoSpacesInTheName MAD_DENISDAILY2 137 — 3y
Log in to vote
0
Answered by 3 years ago

Scripting Helpers is not a request site it is a website where you ask the community to help debug errors with your code and help other people debug errors with their code.

Answer this question