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

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

Asked by
Qu_xtty -8
4 years ago
Edited by Ziffixture 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited by Ziffixture 4 years ago

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)
0
did this work? if so please accept answer tylergoatboy 82 — 4y
1
block.Material = "Neon" is wrong (or deprecated). This is the corrected version: block.Material = Enum.Material.Neon Geobloxia 251 — 4y
0
I did test my version before posting it tylergoatboy 82 — 4y
0
Then it's deprecated. The better way is using Enum. Geobloxia 251 — 4y
View all comments (2 more)
0
But still, it's a good answer. Geobloxia 251 — 4y
0
Please explain why his code isn't working. Ziffixture 6913 — 4y
Ad

Answer this question