local ReplicatedStorage = game:GetService("ReplicatedStorage")
local moveEvent = ReplicatedStorage:WaitForChild("MoveAttachmentOnWall")
-- Allow T (up), F (left), G (down), H (right)
local keyToDirection = {
[Enum.KeyCode.T] = Vector2.new(0, -1), -- Up
[Enum.KeyCode.F] = Vector2.new(-1, 0), -- Left
[Enum.KeyCode.G] = Vector2.new(0, 1), -- Down
[Enum.KeyCode.H] = Vector2.new(1, 0), -- Right
}
local heldKeys = {}
task.spawn(function()
while true do
local moveVec = Vector2.new(0, 0)
for key, held in heldKeys do
if held and keyToDirection[key] then
moveVec = moveVec + keyToDirection[key]
end
end
if moveVec.Magnitude > 0 then
print("Client sending moveVec:", moveVec)
moveEvent:FireServer(moveVec)
end
task.wait(0.02)
end
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
print("Key pressed:", key.Name)
if keyToDirection[key] then
heldKeys[key] = true
end
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
print("Key released:", key.Name)
if heldKeys[key] then
heldKeys[key] = false
end
end
end)```