Sound behaves differently in studio and in game

I’m trying to use the type writer effect shown in this article, but after adding the “voiceClone” part (shown below), there seems to be some issues with it

The problem is that in Studio, the sounds play just fine, but when I get into an actual game, the sounds are all choppy and it’s not consistent

It only seems to be a problem when I use the wait() function, because it’s very consistent and fast if I remove it, as voiceClone.Ended:Wait() is there, which doesn’t seem to behave how wait() does, however I can’t only use voiceClone.Ended:Wait(), since it goes too fast

for f, l in utf8.graphemes(newCaption) do
	index = index+1
	Caption.MaxVisibleGraphemes = index
	local voiceClone = Voice:Clone()
	voiceClone.Parent = script
	voiceClone.PlaybackSpeed = math.random(5, 9)
	voiceClone:Play()
	voiceClone.Ended:Wait()
	debris:AddItem(voiceClone, .1)
	wait(0.03)
end

(not sure if this is the right place, just wondering if there is another way to yield the loop, that doesn’t make the sound inconsistent)

1 Like

Try making the playback speed not be random. Then if this is what make it do weird thing i could try to help you.

sadly the issue persists, it’s no different

Try using PlayLocalSound instead, it should be more reliable. Keep in mind that this can only be used in a local script.

3 Likes

It could work but if he want to make so the whole server hear it then, he would need to use RemoteEvent which exploiter can use to play sound to all the server.

1 Like

True, but the sound id can be stored on the client initially, so no sound ids would be required to retrieve from anywhere else.

Yes but, exploiter could still play the sound with that id. So it would reduce the experience.

2 Likes

thank you, after playing a bit around I got it to work with this code:

newCaption = newCaption:gsub("<br%s*/>", "\n")
newCaption:gsub("<[^<>]->", "")
for f, l in utf8.graphemes(newCaption) do
	index = index+1
	Caption.MaxVisibleGraphemes = index
	local voiceClone = Voice:Clone()
	voiceClone.PlaybackSpeed = math.random(5, 9)
	game:GetService("SoundService"):PlayLocalSound(voiceClone) -- thanks
	debris:AddItem(voiceClone, voiceClone.TimeLength)
	wait(0.03)
end

True, in this case, he can set up the event to ‘Get’ only. So there would be no data sent from the client to the server. Only the text will be ‘get’.