Anchor yourself and toggle animations
Key RequiredUniversal

Anchor yourself and toggle animations

Universal Scriptutku69680utku69680 2.7K views 262 executesUpdated Sep 15, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•198 lines (6677 chars)
-- Services
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

-- Local Player
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AnchorAnimationGui"
screenGui.Parent = playerGui
screenGui.ResetOnSpawn = false

-- Create Main Frame
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 200, 0, 200) -- Increased height for two buttons
mainFrame.Position = UDim2.new(0.5, -100, 0.5, -100)
mainFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Black background
mainFrame.BorderSizePixel = 0
mainFrame.Parent = screenGui

-- Add Rounded Corners to Main Frame
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 15) -- Smooth rounded corners
corner.Parent = mainFrame

-- Create Draggable Top Bar
local topBar = Instance.new("Frame")
topBar.Size = UDim2.new(1, 0, 0, 30)
topBar.BackgroundColor3 = Color3.fromRGB(30, 30, 30) -- Slightly lighter black
topBar.BorderSizePixel = 0
topBar.Parent = mainFrame

-- Add Rounded Corners to Top Bar
local topBarCorner = Instance.new("UICorner")
topBarCorner.CornerRadius = UDim.new(0, 15)
topBarCorner.Parent = topBar

-- Create Title Text in Top Bar
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, 0, 1, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Anchor & Animation"
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
titleLabel.TextScaled = true
titleLabel.Font = Enum.Font.GothamBold
titleLabel.Parent = topBar

-- Create Anchor Button
local anchorButton = Instance.new("TextButton")
anchorButton.Size = UDim2.new(0.8, 0, 0, 50)
anchorButton.Position = UDim2.new(0.1, 0, 0.25, 0)
anchorButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- White button
anchorButton.Text = "Anchor: OFF"
anchorButton.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black text
anchorButton.TextScaled = true
anchorButton.Font = Enum.Font.Gotham
anchorButton.Parent = mainFrame

-- Add Rounded Corners to Anchor Button
local buttonCorner = Instance.new("UICorner")
buttonCorner.CornerRadius = UDim.new(0, 10)
buttonCorner.Parent = anchorButton

-- Create Animation Toggle Button
local animButton = Instance.new("TextButton")
animButton.Size = UDim2.new(0.8, 0, 0, 50)
animButton.Position = UDim2.new(0.1, 0, 0.55, 0) -- Below anchor button
animButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- White button
animButton.Text = "Animations: ON"
animButton.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black text
animButton.TextScaled = true
animButton.Font = Enum.Font.Gotham
animButton.Parent = mainFrame

-- Add Rounded Corners to Animation Button
local animButtonCorner = Instance.new("UICorner")
animButtonCorner.CornerRadius = UDim.new(0, 10)
animButtonCorner.Parent = animButton

-- Dragging Functionality
local dragging
local dragInput
local dragStart
local startPos

local function updateInput(input)
    local delta = input.Position - dragStart
    mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end

topBar.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        dragging = true
        dragStart = input.Position
        startPos = mainFrame.Position

        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
    end
end)

topBar.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        dragInput = input
    end
end)

UserInputService.InputChanged:Connect(function(input)
    if dragging and (input == dragInput) then
        updateInput(input)
    end
end)

-- Anchor Toggle Functionality
local isAnchored = false

anchorButton.MouseButton1Click:Connect(function()
    isAnchored = not isAnchored
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        local humanoidRootPart = player.Character.HumanoidRootPart
        humanoidRootPart.Anchored = isAnchored
        anchorButton.Text = isAnchored and "Anchor: ON" or "Anchor: OFF"
    end
end)

-- Animation Toggle Functionality
local isAnimationsEnabled = true
local animationStopConnection = nil

local function stopAllAnimations(humanoid)
    local animator = humanoid:FindFirstChildOfClass("Animator")
    if animator then
        for _, track in pairs(animator:GetPlayingAnimationTracks()) do
            track:Stop(0)
        end
    end
end

local function toggleAnimations(state)
    if player.Character and player.Character:FindFirstChild("Humanoid") then
        local humanoid = player.Character.Humanoid
        if state then
            -- Enable animations
            if animationStopConnection then
                animationStopConnection:Disconnect()
                animationStopConnection = nil
            end
        else
            -- Disable animations: stop current and prevent new ones
            stopAllAnimations(humanoid)
            if animationStopConnection then
                animationStopConnection:Disconnect()
            end
            animationStopConnection = humanoid.AnimationPlayed:Connect(function(track)
                track:Stop(0)
            end)
        end
        animButton.Text = state and "Animations: ON" or "Animations: OFF"
        isAnimationsEnabled = state
    end
end

animButton.MouseButton1Click:Connect(function()
    isAnimationsEnabled = not isAnimationsEnabled
    toggleAnimations(isAnimationsEnabled)
end)

-- Handle character respawn to reapply animation state
player.CharacterAdded:Connect(function(character)
    local humanoid = character:WaitForChild("Humanoid")
    if not isAnimationsEnabled then
        toggleAnimations(false)
    end
end)

-- Initial setup if character already exists
if player.Character then
    if not isAnimationsEnabled then
        toggleAnimations(false)
    end
end

-- Ensure GUI stays on screen
local function clampToScreen()
    local screenSize = playerGui:GetScreenSize()
    local frameSize = mainFrame.AbsoluteSize
    local posX = math.clamp(mainFrame.Position.X.Offset, 0, screenSize.X - frameSize.X)
    local posY = math.clamp(mainFrame.Position.Y.Offset, 0, screenSize.Y - frameSize.Y)
    mainFrame.Position = UDim2.new(0, posX, 0, posY)
end

mainFrame:GetPropertyChangedSignal("Position"):Connect(clampToScreen)

Features & Information

:D
#Anchor#Animations#Toggle#Update#Yourself

Community Comments (3)

ZERETETZERETETSep 15, 2025

ai

david_Republisherdavid_RepublisherSep 15, 2025

Olá

vaxtalastusvaxtalastusSep 15, 2025

clanker

More Scripts for Universal Scripts