I’m trying to make my script not break whenever the player says something else before the code ends.
It breaks any time the code hasn’t finished and the player says something else. I recorded something so it should help you understand.
The players mouth is supposed to close when the sentence is finished but it infinitely stays open.
I tried adding a debounce but it didn’t seem like it worked.
Anything helps!
player.Chatted:Connect(function(text) --see's if player has said something
--vars
local amt = text.len(text) --detects message length
local waittime = amt / math.random(6, 7.4) --how long the mouth stays open (maths)
local currentmouth = mouth.Texture --saves mouth tex
--texchange
mouth.Texture = "rbxassetid://6376349647" --changes decal
--sound play
sound.Playing = true
--wait
wait(waittime) --waits the chosen time
--sound end
sound.Playing = false
--origtex
mouth.Texture = currentmouth --reverts to original mouth
end)
That’s the part of the code that makes the player talk.