im making a script where if you say something like “lol” it plays a laughing animation and plays a laughing sound. im using string:match() for the chat message
the problem is if you write “haha” it will work but if you write “Haha” it wont
anyone know how to make it do so without needing to write ‘or msg:match(“Haha”)’?
1 Like
string.lower()
or string.upper()
makes a string lowercase or upper case. This could help.
1 Like
how should i use it?
canChat = true
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
plr.Chatted:Connect(function(msg)
if canChat == true then
msg:lower() --should i put it in here like this?
if msg:match("hi") or msg:match("hello") then
local walkspeed = hum.WalkSpeed
local jumppower = hum.JumpPower
hum.WalkSpeed = 0
hum.JumpPower = 0
local anim = hum:LoadAnimation(script.Wave)
anim.Priority= Enum.AnimationPriority.Action
anim.Looped = false
canChat = false
char.Humanoid.Hi:Play()
anim:Play()
wait(1.7)
canChat = true
hum.WalkSpeed = walkspeed
hum.JumpPower = jumppower
anim:Stop()
elseif msg:match("bye") then
local walkspeed = hum.WalkSpeed
local jumppower = hum.JumpPower
hum.WalkSpeed = 0
hum.JumpPower = 0
local anim = hum:LoadAnimation(script.Wave)
anim.Priority= Enum.AnimationPriority.Action
anim.Looped = false
canChat = false
char.Humanoid.Bye:Play()
anim:Play()
wait(1.7)
canChat = true
hum.WalkSpeed = walkspeed
hum.JumpPower = jumppower
anim:Stop()
elseif msg:match("haha") or msg:match("hah") or msg:match("lol") or msg:match("xd") or msg:match("hehe") or msg:match("heh") then
local walkspeed = hum.WalkSpeed
local jumppower = hum.JumpPower
hum.WalkSpeed = 0
hum.JumpPower = 0
local anim = hum:LoadAnimation(script.Laugh)
anim.Priority= Enum.AnimationPriority.Action
anim.Looped = false
canChat = false
char.Humanoid.Haha:Play()
anim:Play()
wait(5)
canChat = true
hum.WalkSpeed = walkspeed
hum.JumpPower = jumppower
anim:Stop()
elseif msg:match("what") or msg:match("huh") or msg:match("?") then
local walkspeed = hum.WalkSpeed
local jumppower = hum.JumpPower
hum.WalkSpeed = 0
hum.JumpPower = 0
local anim = hum:LoadAnimation(script.Confused)
anim.Priority= Enum.AnimationPriority.Action
anim.Looped = false
canChat = false
char.Humanoid.Huh:Play()
anim:Play()
wait(5)
canChat = true
hum.WalkSpeed = walkspeed
hum.JumpPower = jumppower
anim:Stop()
elseif msg:match("yes") or msg:match("yeah") or msg:match("ye") then
local walkspeed = hum.WalkSpeed
local jumppower = hum.JumpPower
hum.WalkSpeed = 0
hum.JumpPower = 0
local anim = hum:LoadAnimation(script.Agree)
anim.Priority= Enum.AnimationPriority.Action
anim.Looped = false
canChat = false
char.Humanoid.Yes:Play()
anim:Play()
wait(2)
canChat = true
hum.WalkSpeed = walkspeed
hum.JumpPower = jumppower
anim:Stop()
end
end
end)
end)
end)
heres my code. i tried putting msg:lower() before the if statements but it doesnt work
msg.match(string.lower("hit"))
Something like that.
Reference:
still nothing. doesnt even return an error.
What you did is almost correct, just overwrite msg with the new lower cased msg.
It would look like the following
local msg = msg:lower() -- this would work
if msg:match("hi") or msg:match("hello") then
2 Likes
system
(system)
Closed
January 7, 2023, 8:19am
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.