I’m having an issue with using Body Velocity for making the player roll forwards.
As you can see from the video, whenever I roll into an object the player’s character just flies around.
local uis = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local rolltime = 0.2
local amt = 50
local maxForce = Vector3.new(math.huge,100,math.huge)
local p = 1000
local debounce = false
local debouncetime = .5
local debris = game:GetService("Debris")
local rollId = "rbxassetid://123975296401615"
local function roll()
if debounce == false then
local vel = Instance.new("BodyVelocity")
vel.Parent = character.Torso
vel.P = p
script.Dash:Play()
vel.MaxForce = maxForce
vel.Velocity = character.Torso.CFrame.lookVector * amt
debris:AddItem(vel,rolltime)
debounce = true
local anim = Instance.new("Animation")
anim.AnimationId = rollId
anim.Name = "roll"
anim = character:FindFirstChild("Humanoid"):LoadAnimation(anim)
anim.Priority = Enum.AnimationPriority.Action
anim:Play()
task.wait(debouncetime)
debounce = false
end
end
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
roll()
end
end)
This is the code responsible for the roll function, can anyone help me find a fix? Thanks!