goopler/src/ReplicatedStorage/ecs/systems/client/sprint.ts
2023-08-12 03:20:20 -07:00

32 lines
No EOL
876 B
TypeScript

import { World } from "@rbxts/matter"
import { match } from "@rbxts/variant"
import { clientState } from "ReplicatedStorage/ecs/state"
function sprint(_: World, client: clientState): void {
if (client.lastProcessedCommand !== undefined) {
match(client.lastProcessedCommand, {
KeyDown: ({ key }) => {
if (key === Enum.KeyCode.LeftControl) {
client.isRunning = true
}
},
KeyUp: ({ key }) => {
if (key === Enum.KeyCode.LeftControl) {
client.isRunning = false
}
},
default: () => {
// do nothing
}
})
}
if (client.isRunning) {
client.character.Humanoid.WalkSpeed = 24
return
}
client.character.Humanoid.WalkSpeed = 16
}
export = sprint