Hello there! I was making a game where you give an npc a teddy bear and they say thanks to you. I've been trying to make a piece of code where when you're holding the tool in your inventory, the npc sensors it and talks to you. Can someone fix up this code for me? Thank you and whoever helps me with this will be in the credits.
local NPC = script.Parent.Parent
local CC = Enum.ChatColor.Red
local proximityprompt = script.Parent.Block.ProximityPrompt
local function Chat(message: string, color)
game:GetService("Chat"):Chat(NPC.Head, message, CC)
end
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
proximityprompt.Triggered:Connect(function(player)
if character:FindFirstChild("teddytool") then
Chat("test")
end
end)
Appreciate it.

3 comments
Is the script a local script? Where is the NPC located, i need to know to help.
its a normal script. the npc is in workspace
Ah, well i was too late anyways, i hope you succeed in making your game, it seems like a cool game.