-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVC_Bypass.lua
69 lines (60 loc) · 2.26 KB
/
VC_Bypass.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
local VoiceChat_Internal = cloneref and cloneref(game:GetService("VoiceChatInternal")) or game:GetService("VoiceChatInternal")
local VoiceChat_Service = cloneref and cloneref(game:GetService("VoiceChatService")) or game:GetService("VoiceChatService")
if getgenv().voiceChat_Check then
warn("Voice Chat already initialized.")
else
getgenv().voiceChat_Check = true
local reconnecting = false
local retryDuration = 3
local maxAttempts = 250
local function unsuspend()
if reconnecting then return warn("Voice Chat Is Still Reconnecting.") end
reconnecting = true
local attempts = 0
while attempts < maxAttempts do
print("Attempting to reconnect to voice chat... Attempt:", attempts + 1)
wait()
VoiceChat_Internal:Leave()
wait(0.2)
VoiceChat_Service:rejoinVoice()
wait(0.1)
VoiceChat_Service:joinVoice()
wait(0.3)
VoiceChat_Internal:Leave()
task.wait(0.3)
VoiceChat_Service:rejoinVoice()
VoiceChat_Service:joinVoice()
wait(0.5)
if VoiceChat_Internal.StateChanged ~= Enum.VoiceChatState.Ended then
print("Successfully reconnected to voice chat!")
reconnecting = false
return
end
attempts = attempts + 1
wait(retryDuration)
end
warn("Failed to reconnect after " .. maxAttempts .. " attempts.")
reconnecting = false
end
local function state_changed_connection(_, newState)
if newState == Enum.VoiceChatState.Ended and not reconnecting then
print("Voice chat disconnected, attempting to reconnect...")
unsuspend()
end
end
VoiceChat_Internal.StateChanged:Connect(state_changed_connection)
end
if VoiceChat_Internal.StateChanged == Enum.VoiceChatState.Ended then
VoiceChat_Internal:Leave()
VoiceChat_Internal:Leave()
task.wait(0.1)
VoiceChat_Service:rejoinVoice()
VoiceChat_Service:joinVoice()
wait()
VoiceChat_Internal:Leave()
wait(0.2)
VoiceChat_Service:rejoinVoice()
VoiceChat_Service:joinVoice()
task.wait(0.2)
VoiceChat_Service:rejoinVoice()
end