Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local player = Players.LocalPlayer
- local driftLerp = 0.01 -- Drift bem escorregadio
- local driftSpeed = 30
- _G.DriftAtivo = false
- -- Detecta se o shiftlock está ativo
- local function isShiftLockActive()
- -- No Roblox padrão, ShiftLockSwitchMode = "MouseLockSwitch"
- -- e CameraMode = "Classic"
- -- Quando shiftlock está ativo, o MouseBehavior é LockCenter
- return UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter
- end
- local function sentarR6(humanoid)
- if humanoid and not humanoid.Sit then
- humanoid.Sit = true
- end
- end
- local function pararSentar(humanoid)
- if humanoid and humanoid.Sit then
- humanoid.Sit = false
- end
- end
- local function driftLoop(char)
- local humanoid = char:WaitForChild("Humanoid")
- local hrp = char:WaitForChild("HumanoidRootPart")
- local vel = Vector3.new()
- RunService.RenderStepped:Connect(function()
- if _G.DriftAtivo and humanoid.Health > 0 then
- sentarR6(humanoid)
- humanoid.WalkSpeed = driftSpeed
- local moveDir = humanoid.MoveDirection
- if moveDir.Magnitude > 0 then
- local targetVel = moveDir.Unit * driftSpeed
- vel = vel:Lerp(targetVel, driftLerp)
- else
- vel = vel:Lerp(Vector3.new(), driftLerp)
- end
- hrp.AssemblyLinearVelocity = Vector3.new(vel.X, hrp.AssemblyLinearVelocity.Y, vel.Z)
- -- Rotação do corpo:
- if isShiftLockActive() then
- -- Shiftlock: corpo segue a câmera
- local cam = workspace.CurrentCamera
- local camLook = cam.CFrame.LookVector
- local lookVec = Vector3.new(camLook.X, 0, camLook.Z).Unit
- hrp.CFrame = CFrame.new(hrp.Position, hrp.Position + lookVec)
- else
- -- Sem shiftlock: corpo segue a direção do movimento
- if vel.Magnitude > 0.1 then
- local lookVec = Vector3.new(vel.X, 0, vel.Z).Unit
- hrp.CFrame = CFrame.new(hrp.Position, hrp.Position + lookVec)
- end
- end
- else
- pararSentar(humanoid)
- humanoid.WalkSpeed = 16
- end
- end)
- end
- local function criarBotaoDrift()
- if player.PlayerGui:FindFirstChild("DriftGui") then return end
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "DriftGui"
- screenGui.ResetOnSpawn = false
- screenGui.Parent = player.PlayerGui
- local btn = Instance.new("TextButton")
- btn.Name = "DriftToggle"
- btn.Size = UDim2.new(0, 80, 0, 30)
- btn.Position = UDim2.new(1, -90, 1, -40)
- btn.BackgroundColor3 = Color3.fromRGB(30,30,30)
- btn.TextColor3 = Color3.new(1,1,1)
- btn.Text = "Drift: OFF"
- btn.TextScaled = true
- btn.BackgroundTransparency = 0.2
- btn.BorderSizePixel = 0
- btn.Parent = screenGui
- btn.MouseButton1Click:Connect(function()
- _G.DriftAtivo = not _G.DriftAtivo
- btn.Text = _G.DriftAtivo and "Drift: ON" or "Drift: OFF"
- end)
- end
- player.CharacterAdded:Connect(function(char)
- criarBotaoDrift()
- driftLoop(char)
- end)
- criarBotaoDrift()
- if player.Character then
- driftLoop(player.Character)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement