--[[
Deepwoken style sprint
]]
-- Services
local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
-- Player & Character Variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Sprint Variables
local sprintSpeed = 26
local defaultSpeed = 16
local lastSprint = tick()
local sprinting = false
local sprintKeys = {
Enum.KeyCode.W,
Enum.KeyCode.A,
Enum.KeyCode.S,
Enum.KeyCode.D,
}
local ticks = {
[Enum.KeyCode.W] = tick(),
[Enum.KeyCode.A] = tick(),
[Enum.KeyCode.S] = tick(),
[Enum.KeyCode.D] = tick()
}
humanoid.WalkSpeed = defaultSpeed
-- Sprint Functions
local function SprintHandler(key, gme)
if gme then return end
if table.find(sprintKeys, key.KeyCode) and not sprinting then
if tick() - ticks[key.KeyCode] <= 0.2 then
sprinting = true
humanoid.WalkSpeed = sprintSpeed
else
ticks[key.KeyCode] = tick()
end
end
end
local function SprintRunService()
if sprinting then
local oneDown = false
for i, v in ipairs(sprintKeys) do
if uis:IsKeyDown(v) then
oneDown = true
end
end
if not oneDown then
sprinting = false
humanoid.WalkSpeed = defaultSpeed
end
end
end
-- Sprint Events
uis.InputBegan:Connect(SprintHandler)
runService.RenderStepped:Connect(SprintRunService)```
#deepwoken style sprint
1 messages · Page 1 of 1 (latest)
👍
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local moving = false
local moveTime = -math.huge
humanoid.Running:Connect(function(speed)
if speed == 0 then
if moving == false then return end
moving = false
humanoid.WalkSpeed = 16
else
if moving == true then return end
moving = true
if time() - moveTime <= 0.2 then humanoid.WalkSpeed = 26 end
moveTime = time()
end
end)
or
local userInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local keys = {[Enum.KeyCode.W] = false, [Enum.KeyCode.A] = false, [Enum.KeyCode.S] = false, [Enum.KeyCode.D] = false}
local keysDown = 0
local keyTime = -math.huge
userInputService.InputBegan:Connect(function(input, processed)
if processed == true then return end
if keys[input.KeyCode] ~= false then return end
keys[input.KeyCode] = true
keysDown += 1
if keysDown ~= 1 then return end
if time() - keyTime <= 0.2 then humanoid.WalkSpeed = 26 end
keyTime = time()
end)
userInputService.InputEnded:Connect(function(input, processed)
if keys[input.KeyCode] ~= true then return end
keys[input.KeyCode] = false
keysDown -= 1
if keysDown ~= 0 then return end
humanoid.WalkSpeed = 16
end)
Lol
why do you use time() over tick() or ostime?
Roblox does not recommend tick
Os.time only updates once per second
Time is the time since the game started so it's a small number
oh i see
deepwoken style sprint mean?
I guess you have to hit the key fast to get into sprint mode?
Deepwoken is a game
ok umm , so it has a certain kind of sprint...
The script is based on how the sprint works in Deepwoken.
if not mistaking
ah ok
If possible is there a way this could be cross-platform.
I've always wondered how to do this for different devices, have never been able to figure out how to detect forward movement on a Analogue Stick however I suppose you could use detection for when the stick is pressed but I am interested to see if someone could detect double forward movement and such. Very nice however! (mobile + console) support is what I wanna try add
this is for all devices
since it uses when humanoid starts running
@mystic lodge
The first one will work on all devices the second only works on keyboard
But it's a little tricky to do on like touch screen you would have to drag the screen 2 times quickly
True, he could make it so if ur moving an button wil pop up called sprint
Yes then the second option would be better as it only works on keyboard
🦧
fair
tick is deprecated!!
whaaaaaaat?