**What do you want to achieve?
I want to have a basic roll script that imitates dark souls rolling.
**What is the issue?
None of the roblox forces I tried worked to achieve that. Every time i put a * 10000 or less it makes it go both sideways and forwards and it only goes truly forwards if I align my character diagonally.
**What solutions have you tried so far?
I have tried Slide, VectorForce, BodyForce.
local Movement = {
["Sprint"] = function(Player, Params)
end,
["Dash"] = function(Player, Params, UserInput)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local humanoid = Character:WaitForChild("Humanoid")
local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
Roll.Priority = Enum.AnimationPriority.Action
local Debounce = false
Debounce = true
Roll:Play()
local slide = Instance.new("BodyVelocity")
slide.MaxForce = Vector3.new(1,0,1) * 10000
slide.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 100
slide.Parent = Character.HumanoidRootPart
for count = 1, 8 do
wait(0.1)
slide.Velocity*= 0.7
end
coroutine.wrap(function()
task.wait(2.5)
Roll:Stop()
end)()
slide:Destroy()
Debounce = false
end,
}
return Movement
idk why that happens, check to see if somewhere else in your script theres a section that pushes the player sideways while you push him forward, its a very obvious thing to say but you never know. Moving on, I have a script that does the exact same thing as yours with bodyVelocity and it works. The only differences between out scripts (on the bodyVelocity part) are these:
Obviously I changed the variable name to match your case, either way I don’t see how any of these changes could solve your problem but maybe they can. Honestly it seems like your script should work fine.
Lastly this is also gonna sound dumb but make sure to check that the HumanoidRootPart of the character isn’t for some reason facing diagonally which would cause the lookvector to send your character diagonally.
Could you give me an example? I can’t seem to figure how to do it.
local Movement = {
["Sprint"] = function(Player, Params)
end,
["Dash"] = function(Player, Params, UserInput)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local humanoid = Character:WaitForChild("Humanoid")
local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
Roll.Priority = Enum.AnimationPriority.Action
local Debounce = false
local tweenService = game:GetService("TweenService")
Debounce = true
local vector3Value = Instance.new("Vector3Value")
vector3Value.Parent = HRP
vector3Value.Value = Vector3.new(0,0,0)
local targetPos = Vector3.new(8,0,8)
local tweenInfo = TweenInfo.new(
2, -- Duration in seconds
Enum.EasingStyle.Linear, -- Easing style (you can choose a different one)
Enum.EasingDirection.In -- Easing direction
)
local tween = tweenService:Create(vector3Value, tweenInfo, {Value = targetPos})
coroutine.wrap(function()
task.wait(2.5)
tween:Play()
Roll:Stop()
end)()
vector3Value:Destroy()
Debounce = false
end,
}
return Movement
local Movement = {
["Sprint"] = function(Player, Params)
end,
["Dash"] = function(Player, Params, UserInput)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local humanoid = Character:WaitForChild("Humanoid")
local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
Roll.Priority = Enum.AnimationPriority.Action
local Debounce = false
local RollStartTime = 0
local RollDirection = Vector3.new()
local RollMult = 15/Roll.Length
Debounce = true
Roll:Play()
RollStartTime = tick()
local dirVec = workspace.CurrentCamera.CFrame.LookVector
RollDirection = (dirVec*Vector3.new(1,0,1)).unit
local LastBeat = tick()
game:GetService("RunService").Heartbeat:Connect(function()
local dT = tick()-LastBeat
LastBeat = tick()
if tick()-RollStartTime < .75 then
HRP.CFrame = CFrame.new(RollDirection*dT*RollMult) * HRP.CFrame
end
end)
Debounce = false
end,
}
return Movement