I’m going to start this post out by saying this: I am NOT a good coder. Not in the slightest. Most of my code is a hodge-podge of code from other places I’ve seen, and while I myself can look at code and go “yeah, I can tell what this does,” my application of this knowledge is terrible. So please be patient with with me, okay? I’m just trying my best here, and this post is proof it wasn’t enough.
Basically, I’m trying to make an easy-to- use parkour system. I got one to work pretty well with BodyVelocity, but I learned later that I probably shouldn’t use it since it’s deprecated, along with the fact there was a wall-clinging bug that was unintended. I was trying to find a solution and I stumbled into VectorForce, which was apparently better for things like momentum and such. I thought: oh, perfect! But I think that it might be a bit out of my pay grade now.
I have non-stop tried to get this to work for three days, and nothing I do can fix it. The issue at the core is that I cannot for the life of me get the character to move. I got them to move once, but I had to put so much velocity on it to move about 2 studs a second on the ground, and then the moment you jumped you’d enter the nth dimension. I redid the code several times with the best of my knowledge, and nothing has been working.
I tried twice to not use VectorForce, but every time I just end up coming back to it since it feels like it’s the closest I’ve gotten to what I wanted. Both times I went to try linear velocity, but both times failed for one reason or another, mostly feeling jank in comparison. I feel like I’m going insane now, like it’s a cursed relic beckoning me.
My formatting probably sucks, but I have a module script running this in ReplicatedStorage,
local ForceController = {}
local characterRefs = {} -- Stores per-character force objects
local debug = true
function ForceController.Init(character)
local hrp = character:WaitForChild("HumanoidRootPart")
if characterRefs[character] then return end
local attachment = Instance.new("Attachment")
attachment.Name = "ForceAttachment"
attachment.Parent = hrp
local vectorForce = Instance.new("VectorForce")
vectorForce.Name = "MainVectorForce"
vectorForce.Attachment0 = attachment
vectorForce.RelativeTo = Enum.ActuatorRelative.World
vectorForce.Force = Vector3.zero
vectorForce.Parent = hrp
characterRefs[character] = {
HumanoidRootPart = hrp,
Attachment = attachment,
VectorForce = vectorForce
}
if debug then print("ForceController initialized for", character.Name) end
end
function ForceController.ApplyForce(character, forceVector, duration)
local data = characterRefs[character]
if not data then return end
local vf = data.VectorForce
vf.Force = forceVector
if debug then
print("Applied force to", character.Name, forceVector, "for", duration or 0.2)
end
if duration and duration > 0 then
task.delay(duration, function()
if vf and vf.Parent then
vf.Force = Vector3.zero
if debug then print("Force reset for", character.Name) end
end
end)
end
end
function ForceController.ZeroForce(character)
local data = characterRefs[character]
if data then
data.VectorForce.Force = Vector3.zero
end
end
return ForceController
and the actual movement code is in a local script in StarterCharacterScripts.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local usi = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = script.Parent.Parent
local ApplyForceEvent = ReplicatedStorage:WaitForChild("ApplyForceEvent")
usi.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Space then
local jumpForce = Vector3.new(0, 2500, 0)
ApplyForceEvent:FireServer(jumpForce, 0.15)
end
if input.KeyCode == Enum.KeyCode.LeftShift then
local hrp = character:WaitForChild("HumanoidRootPart")
local dashDir = hrp.CFrame.LookVector * 4000
ApplyForceEvent:FireServer(dashDir, 0.1)
end
end)
Ideally, what I WANT it to do is to just have slight acceleration and deceleration while moving, to NOT have the dash mechanic (one of the code pieces I looked at just had it in there and I never took it out), and to feel like a less technical parkour game. That’s it.
I’m at my wit’s end with this, and I already had to wait 3 days just to gain access to actually post this, so sorry if I seem short. I’m just so tired.