--// Camera-Relative W/A/S/D Tween Movement --// Draggable Speed GUI + Toggle + Keybinds + Cursor Locker --// LocalScript local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local RunService = game:GetService("RunService") local Player = Players.LocalPlayer --================================================== -- CONFIG --================================================== local MIN_SPEED = 1 local MAX_SPEED = 200 local DEFAULT_SPEED = 50 local STEP_DISTANCE = 5 local Speed = DEFAULT_SPEED local Running = false local Enabled = true local CursorLocked = false --================================================== -- KEYBINDS --================================================== local Keybinds = { Forward = Enum.KeyCode.W, Backward = Enum.KeyCode.S, Left = Enum.KeyCode.A, Right = Enum.KeyCode.D, Toggle = Enum.KeyCode.RightShift, ToggleCursor = Enum.KeyCode.RightControl, } local BindNames = { Forward = "Forward (W)", Backward = "Backward (S)", Left = "Left (A)", Right = "Right (D)", Toggle = "Toggle Script", ToggleCursor = "Cursor Lock", } --================================================== -- KEY STATE --================================================== local Keys = { [Keybinds.Forward] = false, [Keybinds.Backward] = false, [Keybinds.Left] = false, [Keybinds.Right] = false, } local function RebuildKeys() Keys = { [Keybinds.Forward] = false, [Keybinds.Backward] = false, [Keybinds.Left] = false, [Keybinds.Right] = false, } end --================================================== -- CHARACTER --================================================== local function GetRoot() local Character = Player.Character if not Character then return nil end return Character:FindFirstChild("HumanoidRootPart") end --================================================== -- CAMERA-RELATIVE DIRECTION --================================================== local function GetCameraDirection() local Camera = workspace.CurrentCamera if not Camera then return Vector3.zero end local Look = Camera.CFrame.LookVector local Right = Camera.CFrame.RightVector local Forward = Vector3.new(Look.X, 0, Look.Z) local CameraRight = Vector3.new(Right.X, 0, Right.Z) if Forward.Magnitude > 0 then Forward = Forward.Unit end if CameraRight.Magnitude > 0 then CameraRight = CameraRight.Unit end local Direction = Vector3.zero if Keys[Keybinds.Forward] then Direction += Forward end if Keys[Keybinds.Backward] then Direction -= Forward end if Keys[Keybinds.Right] then Direction += CameraRight end if Keys[Keybinds.Left] then Direction -= CameraRight end if Direction.Magnitude == 0 then return Vector3.zero end return Direction.Unit end --================================================== -- MOVEMENT LOOP --================================================== local function AnyMovementKeyDown() for _, v in pairs(Keys) do if v then return true end end return false end local function MovementLoop() if Running then return end Running = true while Enabled and AnyMovementKeyDown() do local Root = GetRoot() if not Root then task.wait() continue end local Direction = GetCameraDirection() if Direction.Magnitude > 0 then local TargetPosition = Root.Position + Direction * STEP_DISTANCE local TargetCFrame = CFrame.new(TargetPosition) * Root.CFrame.Rotation local Duration = STEP_DISTANCE / math.max(Speed, 1) local Tween = TweenService:Create( Root, TweenInfo.new(Duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), { CFrame = TargetCFrame } ) Tween:Play() Tween.Completed:Wait() else task.wait() end end Running = false end --================================================== -- CURSOR LOCKER --================================================== local function SetCursorLock(state) CursorLocked = state if CursorLocked then UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter UserInputService.MouseIconEnabled = false else UserInputService.MouseBehavior = Enum.MouseBehavior.Default UserInputService.MouseIconEnabled = true end end RunService.RenderStepped:Connect(function() if CursorLocked then UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter UserInputService.MouseIconEnabled = false end end) --================================================== -- GUI --================================================== local GUI = Instance.new("ScreenGui") GUI.Name = "TweenSpeedGUI" GUI.ResetOnSpawn = false GUI.Parent = Player:WaitForChild("PlayerGui") local Frame = Instance.new("Frame") Frame.Name = "Main" Frame.Size = UDim2.fromOffset(340, 385) Frame.Position = UDim2.new(0.5, -170, 0.5, -192) Frame.BackgroundColor3 = Color3.fromRGB(24, 24, 24) Frame.BorderSizePixel = 0 Frame.Active = true Frame.Parent = GUI local Corner = Instance.new("UICorner") Corner.CornerRadius = UDim.new(0, 12) Corner.Parent = Frame --================================================== -- TITLE / DRAG --================================================== local Title = Instance.new("TextLabel") Title.Size = UDim2.new(1, -20, 0, 35) Title.Position = UDim2.fromOffset(10, 5) Title.BackgroundTransparency = 1 Title.Text = "Camera Tween Movement" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.TextSize = 20 Title.Font = Enum.Font.GothamBold Title.Parent = Frame local Dragging = false local DragStart local StartPosition Title.InputBegan:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then Dragging = true DragStart = Input.Position StartPosition = Frame.Position end end) UserInputService.InputChanged:Connect(function(Input) if Dragging and Input.UserInputType == Enum.UserInputType.MouseMovement then local Delta = Input.Position - DragStart Frame.Position = UDim2.new( StartPosition.X.Scale, StartPosition.X.Offset + Delta.X, StartPosition.Y.Scale, StartPosition.Y.Offset + Delta.Y ) end end) UserInputService.InputEnded:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then Dragging = false end end) --================================================== -- TOGGLE BUTTON --================================================== local ToggleButton = Instance.new("TextButton") ToggleButton.Size = UDim2.new(1, -30, 0, 28) ToggleButton.Position = UDim2.fromOffset(15, 42) ToggleButton.BackgroundColor3 = Color3.fromRGB(60, 170, 80) ToggleButton.BorderSizePixel = 0 ToggleButton.Text = "🟒 SCRIPT: ON" ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) ToggleButton.TextSize = 15 ToggleButton.Font = Enum.Font.GothamBold ToggleButton.AutoButtonColor = false ToggleButton.Parent = Frame local ToggleCorner = Instance.new("UICorner") ToggleCorner.CornerRadius = UDim.new(0, 8) ToggleCorner.Parent = ToggleButton local function UpdateToggleVisual() ToggleButton.Text = Enabled and "🟒 SCRIPT: ON" or "πŸ”΄ SCRIPT: OFF" ToggleButton.BackgroundColor3 = Enabled and Color3.fromRGB(60, 170, 80) or Color3.fromRGB(170, 60, 60) end ToggleButton.MouseButton1Click:Connect(function() Enabled = not Enabled if not Enabled then for k in pairs(Keys) do Keys[k] = false end Running = false end UpdateToggleVisual() end) --================================================== -- CURSOR LOCK / UNLOCK BUTTON (ЯРКАЯ КНОПКА) --================================================== local CursorButton = Instance.new("TextButton") CursorButton.Size = UDim2.new(1, -30, 0, 40) CursorButton.Position = UDim2.fromOffset(15, 76) CursorButton.BackgroundColor3 = Color3.fromRGB(200, 140, 40) CursorButton.BorderSizePixel = 0 CursorButton.Text = "πŸ”“ UNLOCK CURSOR (RightCtrl)" CursorButton.TextColor3 = Color3.fromRGB(255, 255, 255) CursorButton.TextSize = 14 CursorButton.Font = Enum.Font.GothamBold CursorButton.AutoButtonColor = false CursorButton.Parent = Frame local CursorCorner = Instance.new("UICorner") CursorCorner.CornerRadius = UDim.new(0, 8) CursorCorner.Parent = CursorButton -- Обводка, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΊΠ½ΠΎΠΏΠΊΠ° Π²Ρ‹Π΄Π΅Π»ΡΠ»Π°ΡΡŒ local CursorStroke = Instance.new("UIStroke") CursorStroke.Color = Color3.fromRGB(255, 200, 80) CursorStroke.Thickness = 2 CursorStroke.Parent = CursorButton local function UpdateCursorVisual() if CursorLocked then CursorButton.Text = "πŸ”’ LOCKED β†’ Π½Π°ΠΆΠΌΠΈ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ UNLOCK (RightCtrl)" CursorButton.BackgroundColor3 = Color3.fromRGB(60, 170, 80) CursorStroke.Color = Color3.fromRGB(120, 255, 140) else CursorButton.Text = "πŸ”“ UNLOCKED β†’ Π½Π°ΠΆΠΌΠΈ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ LOCK (RightCtrl)" CursorButton.BackgroundColor3 = Color3.fromRGB(200, 140, 40) CursorStroke.Color = Color3.fromRGB(255, 200, 80) end end CursorButton.MouseButton1Click:Connect(function() SetCursorLock(not CursorLocked) UpdateCursorVisual() end) --================================================== -- SPEED LABEL + SLIDER --================================================== local SpeedLabel = Instance.new("TextLabel") SpeedLabel.Size = UDim2.new(1, -30, 0, 25) SpeedLabel.Position = UDim2.fromOffset(15, 124) SpeedLabel.BackgroundTransparency = 1 SpeedLabel.Text = "Speed: " .. Speed SpeedLabel.TextColor3 = Color3.fromRGB(220, 220, 220) SpeedLabel.TextSize = 15 SpeedLabel.Font = Enum.Font.Gotham SpeedLabel.TextXAlignment = Enum.TextXAlignment.Left SpeedLabel.Parent = Frame local Slider = Instance.new("Frame") Slider.Size = UDim2.new(1, -30, 0, 8) Slider.Position = UDim2.fromOffset(15, 158) Slider.BackgroundColor3 = Color3.fromRGB(55, 55, 55) Slider.BorderSizePixel = 0 Slider.Active = true Slider.Parent = Frame local SliderCorner = Instance.new("UICorner") SliderCorner.CornerRadius = UDim.new(1, 0) SliderCorner.Parent = Slider local Fill = Instance.new("Frame") Fill.Size = UDim2.fromScale((Speed - MIN_SPEED) / (MAX_SPEED - MIN_SPEED), 1) Fill.BackgroundColor3 = Color3.fromRGB(80, 170, 255) Fill.BorderSizePixel = 0 Fill.Parent = Slider local FillCorner = Instance.new("UICorner") FillCorner.CornerRadius = UDim.new(1, 0) FillCorner.Parent = Fill local Knob = Instance.new("TextButton") Knob.Size = UDim2.fromOffset(18, 18) Knob.AnchorPoint = Vector2.new(0.5, 0.5) Knob.Position = UDim2.new((Speed - MIN_SPEED) / (MAX_SPEED - MIN_SPEED), 0, 0.5, 0) Knob.BackgroundColor3 = Color3.fromRGB(255, 255, 255) Knob.BorderSizePixel = 0 Knob.Text = "" Knob.AutoButtonColor = false Knob.Parent = Slider local KnobCorner = Instance.new("UICorner") KnobCorner.CornerRadius = UDim.new(1, 0) KnobCorner.Parent = Knob local SliderDragging = false local function SetSlider(X) local Percent = math.clamp( (X - Slider.AbsolutePosition.X) / Slider.AbsoluteSize.X, 0, 1 ) Speed = math.floor(MIN_SPEED + ((MAX_SPEED - MIN_SPEED) * Percent) + 0.5) local Normalized = (Speed - MIN_SPEED) / (MAX_SPEED - MIN_SPEED) Fill.Size = UDim2.fromScale(Normalized, 1) Knob.Position = UDim2.new(Normalized, 0, 0.5, 0) SpeedLabel.Text = "Speed: " .. Speed end Slider.InputBegan:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then SliderDragging = true SetSlider(Input.Position.X) end end) Knob.InputBegan:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then SliderDragging = true end end) UserInputService.InputChanged:Connect(function(Input) if SliderDragging and Input.UserInputType == Enum.UserInputType.MouseMovement then SetSlider(Input.Position.X) end end) UserInputService.InputEnded:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then SliderDragging = false end end) --================================================== -- KEYBIND SECTION --================================================== local KeybindTitle = Instance.new("TextLabel") KeybindTitle.Size = UDim2.new(1, -30, 0, 22) KeybindTitle.Position = UDim2.fromOffset(15, 180) KeybindTitle.BackgroundTransparency = 1 KeybindTitle.Text = "Keybinds (Π½Π°ΠΆΠΌΠΈ Π½Π° ΠΏΠΎΠ»Π΅ ΠΈ Π·Π°ΠΆΠΌΠΈ ΠΊΠ»Π°Π²ΠΈΡˆΡƒ)" KeybindTitle.TextColor3 = Color3.fromRGB(180, 180, 180) KeybindTitle.TextSize = 12 KeybindTitle.Font = Enum.Font.Gotham KeybindTitle.TextXAlignment = Enum.TextXAlignment.Left KeybindTitle.Parent = Frame local KeyScroll = Instance.new("ScrollingFrame") KeyScroll.Size = UDim2.new(1, -30, 0, 170) KeyScroll.Position = UDim2.fromOffset(15, 204) KeyScroll.BackgroundColor3 = Color3.fromRGB(18, 18, 18) KeyScroll.BorderSizePixel = 0 KeyScroll.CanvasSize = UDim2.new(0, 0, 0, 0) KeyScroll.AutomaticCanvasSize = Enum.AutomaticSize.Y KeyScroll.ScrollBarThickness = 4 KeyScroll.Parent = Frame local KeyScrollCorner = Instance.new("UICorner") KeyScrollCorner.CornerRadius = UDim.new(0, 8) KeyScrollCorner.Parent = KeyScroll local KeyLayout = Instance.new("UIListLayout") KeyLayout.Padding = UDim.new(0, 4) KeyLayout.SortOrder = Enum.SortOrder.LayoutOrder KeyLayout.Parent = KeyScroll local KeyPadding = Instance.new("UIPadding") KeyPadding.PaddingTop = UDim.new(0, 4) KeyPadding.PaddingBottom = UDim.new(0, 4) KeyPadding.PaddingLeft = UDim.new(0, 4) KeyPadding.PaddingRight = UDim.new(0, 4) KeyPadding.Parent = KeyScroll local AwaitingBind = nil local function KeyToString(key) if typeof(key) == "EnumItem" then return key.Name end return tostring(key) end local function MakeBindRow(order, keyName) local Row = Instance.new("Frame") Row.Size = UDim2.new(1, 0, 0, 26) Row.BackgroundTransparency = 1 Row.LayoutOrder = order Row.Parent = KeyScroll local Label = Instance.new("TextLabel") Label.Size = UDim2.new(0.55, 0, 1, 0) Label.Position = UDim2.fromOffset(4, 0) Label.BackgroundTransparency = 1 Label.Text = BindNames[keyName] or keyName Label.TextColor3 = Color3.fromRGB(220, 220, 220) Label.TextSize = 13 Label.Font = Enum.Font.Gotham Label.TextXAlignment = Enum.TextXAlignment.Left Label.Parent = Row local BindBtn = Instance.new("TextButton") BindBtn.Size = UDim2.new(0.4, -8, 1, -4) BindBtn.Position = UDim2.new(0.6, 0, 0, 2) BindBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45) BindBtn.BorderSizePixel = 0 BindBtn.Text = KeyToString(Keybinds[keyName]) BindBtn.TextColor3 = Color3.fromRGB(255, 255, 255) BindBtn.TextSize = 12 BindBtn.Font = Enum.Font.GothamBold BindBtn.AutoButtonColor = false BindBtn.Parent = Row local BtnCorner = Instance.new("UICorner") BtnCorner.CornerRadius = UDim.new(0, 6) BtnCorner.Parent = BindBtn BindBtn.MouseButton1Click:Connect(function() if AwaitingBind and AwaitingBind ~= BindBtn then AwaitingBind.Text = KeyToString(Keybinds[AwaitingBind:GetAttribute("KeyName")]) AwaitingBind.BackgroundColor3 = Color3.fromRGB(45, 45, 45) end AwaitingBind = BindBtn BindBtn.Text = "..." BindBtn.BackgroundColor3 = Color3.fromRGB(80, 120, 200) end) BindBtn:SetAttribute("KeyName", keyName) end for i, keyName in ipairs({"Forward", "Backward", "Left", "Right", "Toggle", "ToggleCursor"}) do MakeBindRow(i, keyName) end UserInputService.InputBegan:Connect(function(Input, Processed) if not AwaitingBind then return end if Input.UserInputType ~= Enum.UserInputType.Keyboard then return end local keyName = AwaitingBind:GetAttribute("KeyName") Keybinds[keyName] = Input.KeyCode AwaitingBind.Text = Input.KeyCode.Name AwaitingBind.BackgroundColor3 = Color3.fromRGB(45, 45, 45) AwaitingBind = nil RebuildKeys() -- Обновим подписи основных ΠΊΠ½ΠΎΠΏΠΎΠΊ CursorButton.Text = CursorLocked and ("πŸ”’ LOCKED β†’ UNLOCK (" .. Keybinds.ToggleCursor.Name .. ")") or ("πŸ”“ UNLOCKED β†’ LOCK (" .. Keybinds.ToggleCursor.Name .. ")") end) --================================================== -- INPUT (горячиС клавиши) --================================================== UserInputService.InputBegan:Connect(function(Input, Processed) if Input.KeyCode == Keybinds.Toggle then Enabled = not Enabled if not Enabled then for k in pairs(Keys) do Keys[k] = false end Running = false end UpdateToggleVisual() return end if Input.KeyCode == Keybinds.ToggleCursor then SetCursorLock(not CursorLocked) UpdateCursorVisual() return end if Processed then return end if not Enabled then return end if Keys[Input.KeyCode] ~= nil then Keys[Input.KeyCode] = true task.spawn(MovementLoop) end end) UserInputService.InputEnded:Connect(function(Input) if Keys[Input.KeyCode] ~= nil then Keys[Input.KeyCode] = false end end) --================================================== -- INIT VISUALS --================================================== UpdateToggleVisual() UpdateCursorVisual() --================================================== -- RESPAWN SAFETY --================================================== Player.CharacterAdded:Connect(function() for Key in pairs(Keys) do Keys[Key] = false end Running = false end)