Skip to content

Commit 895d3a0

Browse files
author
AUTOr986
authored
Implement Auto Dance GUI with AntiLock feature
Add a LocalScript for an Auto Dance GUI with AntiLock functionality. The script includes controls for toggling animations and GUI visibility.
1 parent 830fa79 commit 895d3a0

File tree

1 file changed

+398
-0
lines changed

1 file changed

+398
-0
lines changed

กันล็อค😈

Lines changed: 398 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,398 @@
1+
-- AUTO👾 Dance GUI (LocalScript)
2+
-- วางไฟล์นี้เป็น LocalScript ใต้ StarterGui
3+
-- พฤติกรรม:
4+
-- - เมื่อเปิดกันล็อค (AntiLock) จะเล่นแอนิเมชัน 104767795538635 (วน)
5+
-- - เมื่อปิดกันล็อค จะหยุดแอนิเมชันที่เล่นโดยสคริปต์นี้
6+
-- - มีปุ่มเปิด/ปิด GUI (ปุ่มเล็กที่มุม) เพื่อแสดง/ซ่อนหน้าต่างหลัก
7+
-- - หน้าต่างหลักสามารถย้ายตำแหน่งได้โดยลากจากแถบ title
8+
-- - ปลอดภัยต่อ respawn และตรวจจับแทร็กที่มี AnimationId ตรงกับ ANIM_ID เพื่อหยุด
9+
10+
local Players = game:GetService("Players")
11+
local TweenService = game:GetService("TweenService")
12+
local VirtualUser = game:GetService("VirtualUser")
13+
local UserInputService = game:GetService("UserInputService")
14+
15+
local player = Players.LocalPlayer
16+
17+
-- Animation ID ตามที่ขอ (ใช้เมื่อต้องเล่น/ตรวจจับเพื่อหยุด)
18+
local ANIM_ID = "rbxassetid://104767795538635"
19+
20+
-- สร้าง ScreenGui
21+
local screenGui = Instance.new("ScreenGui")
22+
screenGui.Name = "AUTO👾"
23+
screenGui.ResetOnSpawn = false
24+
screenGui.Parent = player:WaitForChild("PlayerGui")
25+
26+
-- Main window
27+
local mainFrame = Instance.new("Frame")
28+
mainFrame.Name = "Main"
29+
mainFrame.Size = UDim2.new(0, 300, 0, 140)
30+
mainFrame.Position = UDim2.new(0, 20, 0, 80)
31+
mainFrame.AnchorPoint = Vector2.new(0, 0)
32+
mainFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 30)
33+
mainFrame.BorderSizePixel = 0
34+
mainFrame.Parent = screenGui
35+
36+
local uiCorner = Instance.new("UICorner", mainFrame)
37+
uiCorner.CornerRadius = UDim.new(0, 12)
38+
39+
local gradient = Instance.new("UIGradient", mainFrame)
40+
gradient.Color = ColorSequence.new{
41+
ColorSequenceKeypoint.new(0, Color3.fromRGB(30,30,45)),
42+
ColorSequenceKeypoint.new(1, Color3.fromRGB(18,18,28))
43+
}
44+
gradient.Rotation = 90
45+
46+
-- Title (ใช้ลาก)
47+
local title = Instance.new("TextLabel", mainFrame)
48+
title.Size = UDim2.new(1, -24, 0, 36)
49+
title.Position = UDim2.new(0, 12, 0, 8)
50+
title.BackgroundTransparency = 1
51+
title.Text = "AUTO👾"
52+
title.TextColor3 = Color3.fromRGB(200,200,255)
53+
title.Font = Enum.Font.GothamBold
54+
title.TextSize = 20
55+
title.TextXAlignment = Enum.TextXAlignment.Left
56+
title.Name = "Title"
57+
58+
-- Collapse button (ซ่อน/แสดง controls ภายใน)
59+
local openCloseBtn = Instance.new("TextButton", mainFrame)
60+
openCloseBtn.Name = "OpenClose"
61+
openCloseBtn.Size = UDim2.new(0, 36, 0, 36)
62+
openCloseBtn.Position = UDim2.new(1, -48, 0, 8)
63+
openCloseBtn.BackgroundColor3 = Color3.fromRGB(40,40,60)
64+
openCloseBtn.AutoButtonColor = true
65+
openCloseBtn.Text = "▤"
66+
openCloseBtn.TextColor3 = Color3.fromRGB(220,220,255)
67+
openCloseBtn.Font = Enum.Font.GothamMedium
68+
openCloseBtn.TextSize = 20
69+
local ocCorner = Instance.new("UICorner", openCloseBtn)
70+
ocCorner.CornerRadius = UDim.new(0,8)
71+
72+
-- Controls (collapsible)
73+
local controls = Instance.new("Frame", mainFrame)
74+
controls.Name = "Controls"
75+
controls.Size = UDim2.new(1, -24, 1, -56)
76+
controls.Position = UDim2.new(0, 12, 0, 48)
77+
controls.BackgroundTransparency = 1
78+
79+
local function makeButton(name, posY, text)
80+
local btn = Instance.new("TextButton", controls)
81+
btn.Name = name
82+
btn.Size = UDim2.new(1, 0, 0, 36)
83+
btn.Position = UDim2.new(0, 0, 0, posY)
84+
btn.BackgroundColor3 = Color3.fromRGB(50,50,70)
85+
btn.Text = text
86+
btn.TextColor3 = Color3.fromRGB(235,235,255)
87+
btn.Font = Enum.Font.Gotham
88+
btn.TextSize = 16
89+
local c = Instance.new("UICorner", btn)
90+
c.CornerRadius = UDim.new(0,10)
91+
local stroke = Instance.new("UIStroke", btn)
92+
stroke.Color = Color3.fromRGB(80,80,110)
93+
stroke.Transparency = 0.6
94+
return btn
95+
end
96+
97+
-- AntiLock button (เปิด/ปิด) — เมื่อเปิด จะเล่น ANIM_ID
98+
local lockToggleBtn = makeButton("AntiLock", 0, "กันล็อค: ปิด")
99+
100+
-- Small persistent toggle to show/hide the main GUI
101+
local toggleGuiBtn = Instance.new("TextButton")
102+
toggleGuiBtn.Name = "ToggleGUI"
103+
toggleGuiBtn.Size = UDim2.new(0, 44, 0, 44)
104+
toggleGuiBtn.Position = UDim2.new(0, 20, 0, 20) -- มุมซ้ายบน; ปรับได้
105+
toggleGuiBtn.AnchorPoint = Vector2.new(0,0)
106+
toggleGuiBtn.BackgroundColor3 = Color3.fromRGB(35,35,50)
107+
toggleGuiBtn.AutoButtonColor = true
108+
toggleGuiBtn.Text = "AUTO"
109+
toggleGuiBtn.TextColor3 = Color3.fromRGB(220,220,255)
110+
toggleGuiBtn.Font = Enum.Font.GothamBold
111+
toggleGuiBtn.TextSize = 12
112+
toggleGuiBtn.Parent = screenGui
113+
local tgCorner = Instance.new("UICorner", toggleGuiBtn)
114+
tgCorner.CornerRadius = UDim.new(0,10)
115+
local tgStroke = Instance.new("UIStroke", toggleGuiBtn)
116+
tgStroke.Color = Color3.fromRGB(70,70,95)
117+
tgStroke.Transparency = 0.6
118+
119+
-- Collapse/open animation for controls
120+
local opened = true
121+
openCloseBtn.MouseButton1Click:Connect(function()
122+
opened = not opened
123+
local goalSize
124+
if opened then
125+
goalSize = UDim2.new(1, -24, 1, -56)
126+
TweenService:Create(openCloseBtn, TweenInfo.new(0.25), {Rotation = 0}):Play()
127+
else
128+
goalSize = UDim2.new(1, -24, 0, 0)
129+
TweenService:Create(openCloseBtn, TweenInfo.new(0.25), {Rotation = 90}):Play()
130+
end
131+
TweenService:Create(controls, TweenInfo.new(0.3, Enum.EasingStyle.Quad), {Size = goalSize}):Play()
132+
end)
133+
134+
-- Toggle full GUI visibility (persistent small button)
135+
toggleGuiBtn.MouseButton1Click:Connect(function()
136+
mainFrame.Visible = not mainFrame.Visible
137+
-- Visually indicate state on the small button
138+
if mainFrame.Visible then
139+
toggleGuiBtn.BackgroundColor3 = Color3.fromRGB(35,35,50)
140+
toggleGuiBtn.Text = "AUTO"
141+
else
142+
toggleGuiBtn.BackgroundColor3 = Color3.fromRGB(60,20,20)
143+
toggleGuiBtn.Text = "HIDDEN"
144+
end
145+
end)
146+
147+
-- ========== Animation handling ==========
148+
local animation = Instance.new("Animation")
149+
animation.Name = "AutoDanceAnim"
150+
animation.AnimationId = ANIM_ID
151+
152+
local currentTrack = nil
153+
local playLock = false
154+
155+
local function safeStopCurrentTrack()
156+
if currentTrack then
157+
pcall(function()
158+
currentTrack:Stop()
159+
end)
160+
currentTrack = nil
161+
end
162+
end
163+
164+
local function loadAnimationOnAnimator(humanoid)
165+
if not humanoid then return nil end
166+
-- Prefer Animator
167+
local animator = humanoid:FindFirstChildOfClass("Animator")
168+
if not animator then
169+
-- create an Animator under the humanoid (safe client-side)
170+
animator = Instance.new("Animator")
171+
animator.Name = "AUTO_Animator"
172+
animator.Parent = humanoid
173+
end
174+
local ok, track = pcall(function()
175+
return animator:LoadAnimation(animation)
176+
end)
177+
if ok and track then
178+
return track
179+
end
180+
-- Fallback to humanoid:LoadAnimation
181+
ok, track = pcall(function()
182+
return humanoid:LoadAnimation(animation)
183+
end)
184+
if ok and track then
185+
return track
186+
end
187+
return nil
188+
end
189+
190+
local function playDance()
191+
if playLock then return end
192+
playLock = true
193+
local humanoid
194+
local ok = pcall(function()
195+
local char = player.Character or player.CharacterAdded:Wait()
196+
humanoid = char:WaitForChild("Humanoid", 5)
197+
end)
198+
if not ok or not humanoid then
199+
playLock = false
200+
return
201+
end
202+
203+
-- Stop any existing track we started before loading new one
204+
safeStopCurrentTrack()
205+
206+
local ok2, track = pcall(function()
207+
return loadAnimationOnAnimator(humanoid)
208+
end)
209+
track = ok2 and track or nil
210+
if not track then
211+
playLock = false
212+
return
213+
end
214+
215+
track.Priority = Enum.AnimationPriority.Action
216+
track.Looped = true
217+
pcall(function() track:Play() end)
218+
currentTrack = track
219+
playLock = false
220+
end
221+
222+
local function stopDance()
223+
if playLock then return end
224+
playLock = true
225+
safeStopCurrentTrack()
226+
playLock = false
227+
end
228+
229+
-- Stop any playing tracks on a humanoid whose Animation.AnimationId matches ANIM_ID
230+
local function stopSpecifiedDanceOnHumanoid(humanoid)
231+
if not humanoid then return end
232+
pcall(function()
233+
for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
234+
local anim = nil
235+
pcall(function() anim = track.Animation end)
236+
if anim then
237+
-- Compare as strings to be robust
238+
if tostring(anim.AnimationId) == tostring(ANIM_ID) then
239+
pcall(function() track:Stop() end)
240+
end
241+
end
242+
end
243+
end)
244+
end
245+
246+
local function stopDanceOnCurrentCharacter()
247+
local char = player.Character
248+
if not char then return end
249+
local humanoid = char:FindFirstChildOfClass("Humanoid")
250+
if humanoid then
251+
stopSpecifiedDanceOnHumanoid(humanoid)
252+
end
253+
end
254+
255+
-- ========== Anti-lock (Anti-AFK) ==========
256+
local antiLockEnabled = false
257+
local idledConn = nil
258+
259+
local function connectIdled()
260+
if idledConn then return end
261+
idledConn = player.Idled:Connect(function()
262+
pcall(function()
263+
VirtualUser:CaptureController()
264+
VirtualUser:ClickButton2(Vector2.new(0,0))
265+
end)
266+
end)
267+
end
268+
269+
local function disconnectIdled()
270+
if idledConn then
271+
pcall(function() idledConn:Disconnect() end)
272+
idledConn = nil
273+
end
274+
end
275+
276+
local function setAntiLock(on)
277+
antiLockEnabled = on
278+
if antiLockEnabled then
279+
lockToggleBtn.Text = "กันล็อค: เปิด"
280+
connectIdled()
281+
-- เล่นท่าเต้นที่กำหนดเมื่อเปิดกันล็อค
282+
pcall(playDance)
283+
else
284+
lockToggleBtn.Text = "กันล็อค: ปิด"
285+
disconnectIdled()
286+
-- หยุดแทร็กที่เราเล่น และพยายามหยุดแทร็กอื่นๆ ที่มี ANIM_ID เพื่อความแน่นอน
287+
pcall(stopDance)
288+
pcall(stopDanceOnCurrentCharacter)
289+
end
290+
end
291+
292+
lockToggleBtn.MouseButton1Click:Connect(function()
293+
setAntiLock(not antiLockEnabled)
294+
end)
295+
296+
-- ========== Character handling (respawn-safe) ==========
297+
player.CharacterAdded:Connect(function(char)
298+
-- รอ humanoid
299+
local humanoid = char:WaitForChild("Humanoid", 5)
300+
if humanoid then
301+
-- หยุดแทร็กที่อาจค้างมาจากที่อื่นก่อน
302+
pcall(function() stopSpecifiedDanceOnHumanoid(humanoid) end)
303+
end
304+
-- ถ้า anti-lock เปิดอยู่ ให้เริ่มเล่นใหม่และเชื่อม idled
305+
if antiLockEnabled then
306+
connectIdled()
307+
pcall(playDance)
308+
end
309+
end)
310+
311+
player.CharacterRemoving:Connect(function(char)
312+
local humanoid = char:FindFirstChildOfClass("Humanoid")
313+
if humanoid then
314+
pcall(function() stopSpecifiedDanceOnHumanoid(humanoid) end)
315+
end
316+
-- หยุด internal track ref (จะถูกสร้างใหม่หลัง respawn ถ้าจำเป็น)
317+
safeStopCurrentTrack()
318+
end)
319+
320+
-- เรียกตอนเริ่มต้นเพื่อหยุดท่าเต้นที่อาจกำลังเล่นอยู่
321+
pcall(stopDanceOnCurrentCharacter)
322+
setAntiLock(false)
323+
324+
-- ========== Draggable UI ==========
325+
local dragging = false
326+
local dragInput, dragStart
327+
local startPos = mainFrame.Position
328+
329+
local function updateDrag(input)
330+
if not dragging then return end
331+
local delta = input.Position - dragStart
332+
mainFrame.Position = UDim2.new(
333+
startPos.X.Scale,
334+
startPos.X.Offset + delta.X,
335+
startPos.Y.Scale,
336+
startPos.Y.Offset + delta.Y
337+
)
338+
end
339+
340+
title.InputBegan:Connect(function(input)
341+
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
342+
dragging = true
343+
dragStart = input.Position
344+
startPos = mainFrame.Position
345+
input.Changed:Connect(function()
346+
if input.UserInputState == Enum.UserInputState.End then
347+
dragging = false
348+
end
349+
end)
350+
end
351+
end)
352+
353+
title.InputChanged:Connect(function(input)
354+
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
355+
dragInput = input
356+
end
357+
end)
358+
359+
UserInputService.InputChanged:Connect(function(input)
360+
if input == dragInput and dragging then
361+
updateDrag(input)
362+
end
363+
end)
364+
365+
-- Allow dragging also from openCloseBtn (optional)
366+
openCloseBtn.InputBegan:Connect(function(input)
367+
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
368+
dragging = true
369+
dragStart = input.Position
370+
startPos = mainFrame.Position
371+
input.Changed:Connect(function()
372+
if input.UserInputState == Enum.UserInputState.End then
373+
dragging = false
374+
end
375+
end)
376+
end
377+
end)
378+
379+
openCloseBtn.InputChanged:Connect(function(input)
380+
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
381+
dragInput = input
382+
end
383+
end)
384+
385+
-- (ออฟชั่น) hotkey: กด G เพื่อซ่อน/แสดง GUI
386+
UserInputService.InputBegan:Connect(function(input, gameProcessed)
387+
if gameProcessed then return end
388+
if input.KeyCode == Enum.KeyCode.G then
389+
mainFrame.Visible = not mainFrame.Visible
390+
if mainFrame.Visible then
391+
toggleGuiBtn.BackgroundColor3 = Color3.fromRGB(35,35,50)
392+
toggleGuiBtn.Text = "AUTO"
393+
else
394+
toggleGuiBtn.BackgroundColor3 = Color3.fromRGB(60,20,20)
395+
toggleGuiBtn.Text = "HIDDEN"
396+
end
397+
end
398+
end)

0 commit comments

Comments
 (0)