BobloScript.com

Illegal Soccer script: Camera Tween Movement

Published by bebraPublished Sep 11
Open in Roblox
109Views
127Copies
NeverUpdated

Description

Functions

  • Tween Movement

Developer tested with

Windows

  • Potassium

Screenshots

1 image

Script Code

Raw Code
--// Camera-Relative W/A/S/D Tween Movement--// Draggable Speed GUI + Toggle + Keybinds + Cursor Locker--// LocalScriptlocal 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 = 1local MAX_SPEED = 200local DEFAULT_SPEED = 50local STEP_DISTANCE = 5local Speed = DEFAULT_SPEEDlocal Running = falselocal Enabled = truelocal 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.Unitend--==================================================-- MOVEMENT LOOP--==================================================local function AnyMovementKeyDown()	for _, v in pairs(Keys) do		if v then return true end	end	return falseendlocal 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 = falseend--==================================================-- 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	endendRunService.RenderStepped:Connect(function()	if CursorLocked then		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter		UserInputService.MouseIconEnabled = false	endend)--==================================================-- GUI--==================================================local GUI = Instance.new("ScreenGui")GUI.Name = "TweenSpeedGUI"GUI.ResetOnSpawn = falseGUI.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 = 0Frame.Active = trueFrame.Parent = GUIlocal 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 = 1Title.Text = "Camera Tween Movement"Title.TextColor3 = Color3.fromRGB(255, 255, 255)Title.TextSize = 20Title.Font = Enum.Font.GothamBoldTitle.Parent = Framelocal Dragging = falselocal DragStartlocal StartPositionTitle.InputBegan:Connect(function(Input)	if Input.UserInputType == Enum.UserInputType.MouseButton1 then		Dragging = true		DragStart = Input.Position		StartPosition = Frame.Position	endend)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		)	endend)UserInputService.InputEnded:Connect(function(Input)	if Input.UserInputType == Enum.UserInputType.MouseButton1 then		Dragging = false	endend)--==================================================-- 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 = 0ToggleButton.Text = "🟢 SCRIPT: ON"ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)ToggleButton.TextSize = 15ToggleButton.Font = Enum.Font.GothamBoldToggleButton.AutoButtonColor = falseToggleButton.Parent = Framelocal ToggleCorner = Instance.new("UICorner")ToggleCorner.CornerRadius = UDim.new(0, 8)ToggleCorner.Parent = ToggleButtonlocal 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)endToggleButton.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 = 0CursorButton.Text = "🔓 UNLOCK CURSOR  (RightCtrl)"CursorButton.TextColor3 = Color3.fromRGB(255, 255, 255)CursorButton.TextSize = 14CursorButton.Font = Enum.Font.GothamBoldCursorButton.AutoButtonColor = falseCursorButton.Parent = Framelocal 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 = 2CursorStroke.Parent = CursorButtonlocal 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)	endendCursorButton.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 = 1SpeedLabel.Text = "Speed: " .. SpeedSpeedLabel.TextColor3 = Color3.fromRGB(220, 220, 220)SpeedLabel.TextSize = 15SpeedLabel.Font = Enum.Font.GothamSpeedLabel.TextXAlignment = Enum.TextXAlignment.LeftSpeedLabel.Parent = Framelocal 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 = 0Slider.Active = trueSlider.Parent = Framelocal SliderCorner = Instance.new("UICorner")SliderCorner.CornerRadius = UDim.new(1, 0)SliderCorner.Parent = Sliderlocal 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 = 0Fill.Parent = Sliderlocal FillCorner = Instance.new("UICorner")FillCorner.CornerRadius = UDim.new(1, 0)FillCorner.Parent = Filllocal 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 = 0Knob.Text = ""Knob.AutoButtonColor = falseKnob.Parent = Sliderlocal KnobCorner = Instance.new("UICorner")KnobCorner.CornerRadius = UDim.new(1, 0)KnobCorner.Parent = Knoblocal SliderDragging = falselocal 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: " .. SpeedendSlider.InputBegan:Connect(function(Input)	if Input.UserInputType == Enum.UserInputType.MouseButton1 then		SliderDragging = true		SetSlider(Input.Position.X)	endend)Knob.InputBegan:Connect(function(Input)	if Input.UserInputType == Enum.UserInputType.MouseButton1 then		SliderDragging = true	endend)UserInputService.InputChanged:Connect(function(Input)	if SliderDragging and Input.UserInputType == Enum.UserInputType.MouseMovement then		SetSlider(Input.Position.X)	endend)UserInputService.InputEnded:Connect(function(Input)	if Input.UserInputType == Enum.UserInputType.MouseButton1 then		SliderDragging = false	endend)--==================================================-- KEYBIND SECTION--==================================================local KeybindTitle = Instance.new("TextLabel")KeybindTitle.Size = UDim2.new(1, -30, 0, 22)KeybindTitle.Position = UDim2.fromOffset(15, 180)KeybindTitle.BackgroundTransparency = 1KeybindTitle.Text = "Keybinds (нажми на поле и зажми клавишу)"KeybindTitle.TextColor3 = Color3.fromRGB(180, 180, 180)KeybindTitle.TextSize = 12KeybindTitle.Font = Enum.Font.GothamKeybindTitle.TextXAlignment = Enum.TextXAlignment.LeftKeybindTitle.Parent = Framelocal 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 = 0KeyScroll.CanvasSize = UDim2.new(0, 0, 0, 0)KeyScroll.AutomaticCanvasSize = Enum.AutomaticSize.YKeyScroll.ScrollBarThickness = 4KeyScroll.Parent = Framelocal KeyScrollCorner = Instance.new("UICorner")KeyScrollCorner.CornerRadius = UDim.new(0, 8)KeyScrollCorner.Parent = KeyScrolllocal KeyLayout = Instance.new("UIListLayout")KeyLayout.Padding = UDim.new(0, 4)KeyLayout.SortOrder = Enum.SortOrder.LayoutOrderKeyLayout.Parent = KeyScrolllocal 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 = KeyScrolllocal AwaitingBind = nillocal function KeyToString(key)	if typeof(key) == "EnumItem" then		return key.Name	end	return tostring(key)endlocal 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)endfor i, keyName in ipairs({"Forward", "Backward", "Left", "Right", "Toggle", "ToggleCursor"}) do	MakeBindRow(i, keyName)endUserInputService.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)	endend)UserInputService.InputEnded:Connect(function(Input)	if Keys[Input.KeyCode] ~= nil then		Keys[Input.KeyCode] = false	endend)--==================================================-- INIT VISUALS--==================================================UpdateToggleVisual()UpdateCursorVisual()--==================================================-- RESPAWN SAFETY--==================================================Player.CharacterAdded:Connect(function()	for Key in pairs(Keys) do		Keys[Key] = false	end	Running = falseend)
Latest changeScript published9d ago

Comments

Loading comments…