Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a brick's color and material change when a certain phrase or word is said?

I don't see what I'm doing wrong. Please help!

local message = "A light in the Darkness"
local ErnestaLight = script.Parent
function onChatted(msg, recipent, speaker)
	local sourse = string.lower(speaker.Name)
	msg = string.lower(msg)
	if (msg == message) then
		for i = 1, 9 do
			ErnestaLight.BrickColor.Name("Really red")
			ErnestaLight.Material.Name("Neon")
		end
	end
end

1 answer

✓ Accepted answer

hope this helps

local players = game:GetService("Players")

local block = script.Parent -- The block we're manipulating 

local text = "A light in the Darkness" -- Match to what they chatted

local function onChatted(chatMessage, recipient, speaker) 
	if (recipient) then return end
	if (chatMessage:lower() == text:lower()) then 
		block.BrickColor = BrickColor.new("Really red") 
		block.Material = Enum.Material.Neon
	end 
end 

players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(onChatted) 
end)

6 comments

0

did this work? if so please accept answer

1

block.Material = "Neon" is wrong (or deprecated). This is the corrected version: block.Material = Enum.Material.Neon

0

I did test my version before posting it

0

Then it's deprecated. The better way is using Enum.

0

But still, it's a good answer.

0

Please explain why his code isn't working.

This discussion is preserved as it was. New answers, comments, and votes are closed.