Press C to roll

How would I make it so when I press C to roll, for example when I would press C I would get a slight boost that pushes you forward. When you press the button a animation would also play. How would I also make a cooldown between each “roll”?

I already have the animation done for it. This game is also in R6

3 Likes

look into this:

then, for the cooldown use a debounce, like

local canRoll = true
WhenCPressed:Connect(function()
     if not canRoll then return end
     rollAnimation:Play()
     canRoll = false
     wait(3)
     canRoll = true
end)
3 Likes

You will also want to look in to bodyVelocity, this will make your character move forward when they press the desired button and use UserInputService.
This is how you would get C

UserInputService works great for getting keyboard actions.
BodyVelocity

Setting the bodyVelocity to your lookVector (CFrame | Documentation - Roblox Creator Hub) will make your player roll where ever they are looking,

I don’t understand in the body velocity how it would push me forward or where it says it. And by looking do you mean where their mouse is or where their body is facing?

BodyVelocity basically is an unseen force (like gravity) that pushes against a basepart.

So I’ll show you a demo script(Read the notes, they will help you understand)

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local function Roll(Player) -- You would get the Player from firing of a remoteEvent
local Root = game.Player.Character:WaitForChild("HumanoidRootPart") -- Your Characters torso
local BV = instance.new("BodyVelocity") -- Making the Force
BV.MaxForce = Vector3.New(math.Huge, math.Huge, math.Huge) -- Don't worry about this
BV.Velocity = Root.CFrame.LookVector * 90 -- The number is the speed, LookVector gets where the part is facing
BV.Parent = Root -- Puts the force in the Torso
delay(0.5, function()
BV:Destroy() -- Removes Bv so character doesn't get pushed forever(aka. how long the dash is)
end)
end)
RemoteEvent.OnServerEvent:Connect(Roll) -- You have a remoteEvent fire from a local script(This will be where your UserInputService is at)
1 Like

How would I put that into the roll script though? I’m guessing this is how far it woudl push you.

BV.Velocity = Root.CFrame.LookVector * 90