local player = game.Players.LocalPlayer local userInputService = game:GetService("UserInputService") local isUsingSetA = true -- Animation Sets local animSetA = { idle = "rbxassetid://135419935358802", -- Current idle walk = "rbxassetid://108287960442206" -- Current walk } local animSetB = { idle = "rbxassetid://74530436512522", -- Old idle walk = "rbxassetid://109671225388655" -- Old walk } local currentSet = animSetA local walkTrack, idleTrack local runningConnection -- Function to load animations local function applyAnimations(character) local humanoid = character:WaitForChild("Humanoid") humanoid.WalkSpeed = 24 if walkTrack then walkTrack:Stop() end if idleTrack then idleTrack:Stop() end if runningConnection then runningConnection:Disconnect() end local walkAnim = Instance.new("Animation") walkAnim.AnimationId = currentSet.walk walkTrack = humanoid:LoadAnimation(walkAnim) local idleAnim = Instance.new("Animation") idleAnim.AnimationId = currentSet.idle idleTrack = humanoid:LoadAnimation(idleAnim) runningConnection = humanoid.Running:Connect(function(speed) if speed > 0 then idleTrack:Stop() if not walkTrack.IsPlaying then walkTrack:Play() end else walkTrack:Stop() if not idleTrack.IsPlaying then idleTrack:Play() end end end) end -- Function to handle touch events local lastTapTime = 0 local tapThreshold = 0.5 -- 0.5 seconds buffer to distinguish between camera adjustments and taps local function handleTouch(input) local tapped = input.Position local currentTime = tick() -- Check if enough time has passed to register a deliberate tap if currentTime - lastTapTime > tapThreshold then -- Update last tap time lastTapTime = currentTime -- Define a buffer region for the tap area local bufferArea = Rect.new(50, 50, 150, 150) -- Top-left region: (50, 50) to (150, 150) -- Check if the tap is inside the buffer area if bufferArea:Contains(tapped) then isUsingSetA = not isUsingSetA currentSet = isUsingSetA and animSetA or animSetB if player.Character then applyAnimations(player.Character) end end end end -- We will track whether the initial code has been executed local hasExecuted = false -- Function to initialize only once local function initializeAnimations() -- Initialize the animation only once on the first load, not after reset if not hasExecuted then hasExecuted = true -- Apply animations to the initial character only if player.Character then applyAnimations(player.Character) end -- Create GUI in PlayerGui local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui")) screenGui.Name = "AnimToggleGui" -- Create the button local button = Instance.new("TextButton") button.Size = UDim2.new(0, 120, 0, 40) button.Position = UDim2.new(1, -130, 0.5, -20) button.Text = "Toggle Anim" button.BackgroundColor3 = Color3.fromRGB(70, 70, 200) button.TextColor3 = Color3.new(1, 1, 1) button.Font = Enum.Font.GothamBold button.TextSize = 14 button.Parent = screenGui -- Connect button click to toggle animations button.MouseButton1Click:Connect(function() isUsingSetA = not isUsingSetA currentSet = isUsingSetA and animSetA or animSetB if player.Character then applyAnimations(player.Character) end end) -- Connect the touch event handler userInputService.TouchStarted:Connect(handleTouch) end end -- Run the initialization when the player first loads initializeAnimations() -- Ensure that on respawn, the code does not execute again player.CharacterAdded:Connect(function(character) if not hasExecuted then initializeAnimations() end end)