local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local minHoldTime = 0.3 -- minimum amount of time holding the key
local maxHoldTime = 2.0 -- maximum amount of time holding the key
local minInterval = 5.0 -- miminum amount of time inbetween key presses
local maxInterval = 20.0 -- maximum amount of time inbetween key presses
local walkSpeed = 16
local function getRandom(min, max)
return math.random() * (max - min) + min
end
local function stopMovement()
if rootPart and rootPart.Parent then
rootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
end
end
player.CharacterAdded:Connect(function(newChar)
stopMovement()
character = newChar
rootPart = character:WaitForChild("HumanoidRootPart")
humanoid = character:WaitForChild("Humanoid")
end)
local cardinalDirections = {
Vector3.new(0, 0, 1), -- w
Vector3.new(-1, 0, 0), -- a
Vector3.new(0, 0, -1), -- s
Vector3.new(1, 0, 0) -- d
}
while true do
if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") then
wait(1)
continue
end
local waitTime = getRandom(minInterval, maxInterval)
print("Waiting " .. math.floor(waitTime) .. " seconds...")
for i = 1, waitTime * 10 do
wait(0.1)
if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") then
break
end
end
if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") then
continue
end
local directionIndex = math.random(1, 4)
local directionVector = cardinalDirections[directionIndex]
local moveDuration = getRandom(minHoldTime, maxHoldTime)
local endTime = tick() + moveDuration
print("Moving in cardinal direction...")
while tick() < endTime and player.Character and player.Character:FindFirstChild("HumanoidRootPart") do
if rootPart.Parent then
local currentPos = rootPart.CFrame.Position
local targetLookAt = currentPos + directionVector
rootPart.CFrame = CFrame.new(currentPos, targetLookAt)
rootPart.AssemblyLinearVelocity = directionVector * walkSpeed
end
RunService.RenderStepped:Wait()
end
stopMovement()
print("Stopped.")
wait(0.1)
end
Comments
No comments yet
Be the first to share your thoughts!