This is a talking TV based off of user chatting!
It does the job, it works. I just want to know what you guys would’ve done differently, as I am somewhat new to scripting.
And is this considerably decent code?
game.Players.PlayerAdded:Connect(function(player)
local screen = game.Workspace.Screen.screenGUI.TextBox
local greetingDictionary = {
'hello', 'hi', 'hey', 'yo', 'sup'
}
local responseDictionary = {'Hey there!', 'How are you?', 'What are you doing?'}
local userResponse1 = {'im good', 'good'}
local userResponse2 = {'nothing'}
local tvResponse1 = {'That is good to hear. I am a TV, I dont have feelings.'}
player.Chatted:Connect(function(msg)
for i, v in pairs(greetingDictionary) do
if msg == v then
local chosenResponse = math.random(1, #responseDictionary)
if chosenResponse == 1 then
screen.Text = responseDictionary[chosenResponse]
elseif chosenResponse == 2 then
screen.Text = responseDictionary[chosenResponse]
elseif chosenResponse == 3 then
screen.Text = responseDictionary[chosenResponse]
end
end
end
for i, v in pairs(userResponse1) do
if msg == v then
screen.Text = tvResponse1[1]
end
end
if msg == "nothing" then
screen.Text = 'Oh. I am just talking to ROBLOXIANS.'
end
end)
end)