Character flings when dashing/rolling

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!

Im not sure if this will work, i would use a raycast with run service on the roll, and if the raycast hits (lets say, a wall.), Just remove the velocity so it wont fling the character.

welp thats a solution probably, ill try it later!

i made the script and it works perfectly, thanks so much!!!

1 Like

change the max force x and z to something lower like 100000, otherwise your character will fling.

1 Like

guess that works too

""

charactersss

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.