32 lines
No EOL
876 B
TypeScript
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 |