Snap Tap Movement

腳本程式碼
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
-- Wait for character and humanoid
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
player.CharacterAdded:Connect(function(newCharacter)
character = newCharacter
humanoid = newCharacter:WaitForChild("Humanoid")
end)
-- Disable default controls
local PlayerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local controls = PlayerModule:GetControls()
controls:Disable()
-- Input tracking
local keys = {
[Enum.KeyCode.W] = false,
[Enum.KeyCode.S] = false,
[Enum.KeyCode.A] = false,
[Enum.KeyCode.D] = false,
[Enum.KeyCode.Space] = false
}
-- Last pressed stacks for opposing directions
local verticalStack = {} -- W, S
local horizontalStack = {} -- A, D
local function removeFromStack(stack, key)
for i = #stack, 1, -1 do
if stack[i] == key then
table.remove(stack, i)
end
end
end
local function updateStack(stack, key, isPressed)
removeFromStack(stack, key)
if isPressed then
table.insert(stack, key)
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if keys[input.KeyCode] ~= nil then
keys[input.KeyCode] = true
if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S then
updateStack(verticalStack, input.KeyCode, true)
elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
updateStack(horizontalStack, input.KeyCode, true)
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if keys[input.KeyCode] ~= nil then
keys[input.KeyCode] = false
if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S then
updateStack(verticalStack, input.KeyCode, false)
elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
updateStack(horizontalStack, input.KeyCode, false)
end
end
end)
RunService.RenderStepped:Connect(function()
if not humanoid or not character:IsDescendantOf(workspace) then return end
-- Handle jumping
if keys[Enum.KeyCode.Space] then
humanoid.Jump = true
end
local moveDir = Vector3.new(0, 0, 0)
-- Vertical movement (Snap Tap)
if #verticalStack > 0 then
local activeKey = verticalStack[#verticalStack]
if activeKey == Enum.KeyCode.W then
moveDir += Vector3.new(0, 0, -1)
elseif activeKey == Enum.KeyCode.S then
moveDir += Vector3.new(0, 0, 1)
end
end
-- Horizontal movement (Snap Tap)
if #horizontalStack > 0 then
local activeKey = horizontalStack[#horizontalStack]
if activeKey == Enum.KeyCode.A then
moveDir += Vector3.new(-1, 0, 0)
elseif activeKey == Enum.KeyCode.D then
moveDir += Vector3.new(1, 0, 0)
end
end
if moveDir.Magnitude > 0 then
humanoid:Move(moveDir.Unit, true)
else
humanoid:Move(Vector3.new(0, 0, 0), true)
end
end)
描述
Snap Tap is an advanced movement feature that gives instant priority to the most recently pressed movement key. When two opposite movement keys (such as A and D, or W and S) are held at the same time, the latest key pressed automatically becomes active without requiring the other key to be released. This allows for faster direction changes, smoother movement, and more responsive controls during gameplay. Once the active key is released, control instantly returns to the previously held key.
評論 (0)
- 成為第一個評論的人。
常見問題
- 如何使用 Snap Tap Movement 腳本?
- 複製上方的腳本程式碼,開啟你的 Roblox 執行器,貼上程式碼,然後在遊戲中點擊執行。腳本執行後功能會立即啟用。
- Snap Tap Movement 腳本免費嗎?
- 是的。此腳本免費複製和使用。如果使用金鑰系統,請透過「獲取金鑰」連結免費解鎖。
- 使用 Snap Tap Movement 腳本安全嗎?
- 完整原始碼顯示在此頁面上,讓你在執行前準確了解其功能。請始終使用可信的執行器,並記住使用腳本違反 Roblox 服務條款,風險自負。
- 哪個執行器相容 Snap Tap Movement?
- 此腳本相容大多數熱門 Roblox 執行器。查看我們的執行器頁面,為你的裝置找到可信的免費或付費執行器。