Hi! I have this script so if a player says something in chat correctly, the door opens:
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
local decal = script.Parent:FindFirstChildOfClass('Decal')
msg = string.lower(msg)
local thecharacter = script.Parent.TheCharacter
print(msg)
print(thecharacter.Value)
print(script.Parent.TheCharacter2.Value)
if (msg == string.lower(thecharacter.Value or script.Parent.TheCharacter2.Value)) then
local value = game.ReplicatedStorage.Value.Value
if value == true then
door.CanCollide = false
image.Visible = true
image:TweenPosition(UDim2.new(0.3, 0,0.3, 0), "Out",1)
door.Transparency = 0.7
decal.Transparency = 0.7
wait(3)
image:TweenPosition(UDim2.new(1, 0,0.3, 0), "Out",1)
wait(1)
image.Visible = false
image.Position = UDim2.new(-0.4, 0, 0.3, 0)
door.CanCollide = true
door.Transparency = 0
decal.Transparency = 0
end
end
end
game.Players.ChildAdded:connect(function(plr)
plr.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, plr) end)
end)
The problem is, string.lower isn’t working correctly. To try and debug it, I added the 3 print statements that print the original players message, and the two values to make sure they matched and they did. I am kind of stuck as to what to change. Can anyone help me?