I want to create a custom movement system for wich i choose to make a velocity based one.
My problem is that im fairly new to scripting so i have almost no clue how to make one.
I’ve looked trough the devforum but i couldn’t find anything suitable.
I want to make this movement system as close to that from parkour reborn as possible but just the moving not like wallclimb or smth.
What i mean by that is to replace the default walkspeed movement system in roblox with a velocity based one that also keeps your velocity if you are jumping/falling and releasing wasd.
I hope you understand what i mean im sorry if its confusing but it would be great if you can help me.
Im not entirely sure how to do it, but using ContextActionService you can override the basic inputs for walking (and I think also jumping!)
With that you can use something in roblox physics (like a VectorForce) to make the velocity go up when you press W and go down when you let go of it. Just use math functions to determine the exact movement of it.
You can put a local script in startplayerscripts and paste this
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local speed = 50
local velocity = Vector3.new(0, 0, 0)
local function updateVelocity()
local moveDirection = Vector3.new(0, 0, 0)
if userInputService:IsKeyDown(Enum.KeyCode.W) then
moveDirection = moveDirection + Vector3.new(0, 0, -1)
end
if userInputService:IsKeyDown(Enum.KeyCode.S) then
moveDirection = moveDirection + Vector3.new(0, 0, 1)
end
if userInputService:IsKeyDown(Enum.KeyCode.A) then
moveDirection = moveDirection + Vector3.new(-1, 0, 0)
end
if userInputService:IsKeyDown(Enum.KeyCode.D) then
moveDirection = moveDirection + Vector3.new(1, 0, 0)
end
moveDirection = moveDirection.Unit * speed
velocity = Vector3.new(moveDirection.X, velocity.Y, moveDirection.Z)
end
runService.RenderStepped:Connect(function()
updateVelocity()
rootPart.Velocity = velocity
end)
humanoid.Jumping:Connect(function()
velocity = Vector3.new(velocity.X, 50, velocity.Z)
end)