I want to make a NPC using the Dialog object (If possible) that if you have a certain tool the NPC says one thing but if you don't have the tool says another thing. I have tried lots of things but nothing seems to work. The script is located inside of a bunch of models and folders in workspace. The script is NOT a module or local script.
Here is what I tried:
local Tool = game.Players.LocalPlayer.Backpack:GetChildren() --[[ Creates a table of all the objects inside the players backpack]]--
-- Creates a function that checks if the player has of does not have the tool
local function dialog()
-- Loops around the players backpack
for i, v in pairs(Tool) do
print(v)
-- Checks if v is == the tool (The tool is named "Artifact")
if v.Name == "Artifact" and v:IsA("Tool") then
print("You have the tool")
-- Changes the dialog
script.Parent.InitialPrompt = "You found it! Take it to the gate to open it."
else
-- Changes the dialog if the player does not have the tool
script.Parent.InitialPrompt = "I don't see an artifact! You need the artifact to get in!"
end
end
end
-- Checks if the dialog is in use. If it is then the function above will run
if script.Parent.InUse == true then
dialog()
end
I don't know if this is possible without coding my own dialog system but if there is a way then please help!
Any help appreciated! Thanks!

2 comments
Thanks! I will try this out!
Np :D