Help to create a roblox voice mechanic, like lore game

I want to play a sound for each word in a chat that a player sends, like lore game.

The issue is I just cant quite replicate it, and that I might need some assistance to do so.

I have tried looking through the dev forum for solutions, but I have not found any that fit my goal.

my game :

lore game :

here is my code that i am currently using.
Client:

task.wait(3)

game.Players.LocalPlayer.Chatted:Connect(function(message)
	game.ReplicatedStorage.BeepVoice:FireServer(message)
end)

Server :

game.ReplicatedStorage.BeepVoice.OnServerEvent:Connect(function(plr,message)
	local amount = 1
	for Letter = 1,#message do 
		amount += 1
		if string.sub(message,Letter,Letter) == "." then
			print("Full stop")
			task.wait(0.5)
		elseif string.sub(message,Letter,Letter) == "," then
			print("Comma")
			task.wait(0.25)
		else
			if amount == 3 then
				amount = 1
				local sound = script.Sound:Clone()
				sound.Parent = plr.Character.Head
				sound.PitchShiftSoundEffect.Octave = math.random(5,6)/10
				sound:Destroy()
				task.wait(0.1)
			end
		end

	end
end)

If you know how to make it sound like the one in lore game, please do tell me how.
Thanks :smiley:

All you have to do in practice would be to make the pitch lower and increase the delay between each sound, If you can’t figure out the specifics through code I’m sure someone here can help. Though I challenge you to try and figure it out yourself and see how it goes.

is there not a way to detect if its a full word and then play a sound?

Oh sorry I didn’t think that was the problem, Yes there are ways to do that. You could count the amount of spaces and play a sound for each space + one for the starting word, I will look through the Roblox API on strings real quick for anything that can help.

Alright after an hour of tinkering around I got this to work really really well

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(message)
		coroutine.wrap(function()
			local function PlaySound()
				--YOUR CODE TO PLAY AUDIO HERE
			end
			local Words = string.split(message, " ")
			for _, V in pairs(Words) do
				PlaySound()
				if string.match(V,"%p") ~= nil then
					if string.match(message,"%p") == "." then
						wait(0.3)
						print("Period")
					elseif string.match(message,"%p") == "," then
						wait(0.2)
						print("Comma")
					end
				else
					wait(0.1)
					print("none")
				end
			end
		end) ()
	end)
end)

All of this can go in one Serverscript, no remote events or Localscript needed. doctor it up and tell me how if it works for you. (also don’t forget to change the time it waits to your liking)

7 Likes

I decided to play around with the script and it’s very fun to use, my little mouse character squeaks when it talks now. This is very fun.

1 Like

After tweaking it a little it works just great, thanks!

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.