o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
make a roblox script that i can put inside of a npc that will make it say hi
- User
make a roblox script that i can put inside of a npc that will make it say hi
- Assistant
make a roblox script that i can put inside of a npc that will make it say hi
Sure! You can create a simple script that makes your NPC say "Hi" using the Chat service in Roblox. Here's how you can do it:
-- Place this Script inside your NPC model
local ChatService = game:GetService("Chat")
local NPC = script.Parent
-- Make the NPC say "Hi"
ChatService:Chat(NPC.Head, "Hi", Enum.ChatColor.White)
Instructions:
Insert an NPC into Your Game:
Add a Script to the NPC:
Paste the Script:
Test the Script:
Explanation:
game:GetService("Chat") retrieves the Chat service, which allows you to make characters display chat messages.ChatService:Chat(NPC.Head, "Hi", Enum.ChatColor.White) tells the Chat service to display the message "Hi" above the NPC's head.
NPC.Head specifies where the chat bubble appears (above the NPC's head)."Hi" is the message that will be displayed.Enum.ChatColor.White sets the color of the text in the chat bubble.Optional Enhancements:
Change the Message:
"Hi" with your desired message.
ChatService:Chat(NPC.Head, "Welcome to our game!", Enum.ChatColor.White)
Add a Delay or Loop:
wait function.
while true do
ChatService:Chat(NPC.Head, "Hi", Enum.ChatColor.White)
wait(5) -- Waits for 5 seconds before saying Hi again
end
Respond to Player Proximity:
Touched event.
local ChatService = game:GetService("Chat")
local NPC = script.Parent
local function onTouched(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
ChatService:Chat(NPC.Head, "Hi " .. player.Name .. "!", Enum.ChatColor.White)
end
end
NPC.HumanoidRootPart.Touched:Connect(onTouched)
Tips:
Let me know if you have any questions or need further assistance customizing your NPC's behavior!
Not yet included in a published release.