Imgflip Logo Icon
IVY; I GOCHU SCRIPT | made w/ Imgflip meme maker
126 views Made by EdEnStonne 2 years ago
46 Comments
0 ups, 2y,
3 replies
The second version I recommend is with ContextActionService, which allows you to bind and unbind action, so you can basically disable the dash if you need to :

local CAS = game:GetService('ContextActionService')
local Player = game:GetService('Players').LocalPlayer
repeat task.wait() until Player.Character
local Character = Player.Character
local HumanoidPart = Player.Character:WaitForChild("HumanoidRootPart") -- Find the Root Part of the Character
local Humanoid = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid of the Character
local Gravity = workspace.Gravity

-- Modified the variables a bit so it worked properly
local DashTime = 0.2 -- Time the force apply
local Amount = 400 -- Dash force
local Cooldown = false -- Cooldown Lock
local CooldownTime = 2 -- Cooldown Time

local function Dash(actionName, inputState, inputObject)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin and Cooldown == false then
Cooldown = true -- I prefer to always put the variable lock on top
local CharacterOrientation = math.rad(HumanoidPart.Orientation.Y - 180) -- Find the orientation of it
-- It was backward for some reason so I just subtract 180 degres
local DashVelocity = Vector2.new(
math.sin(CharacterOrientation),
math.cos(CharacterOrientation)) * Amount -- With a little bit of math, there is the dash velocity stored in a vector 2
script.Dash:Play() --I don't have the script.Dash so I trust you on that one
if Humanoid.FloorMaterial ~= Enum.Material.Air then
HumanoidPart:ApplyImpulse(Vector3.new(0,2000,0)) -- Makes the character airborn
wait()
end
HumanoidPart.AssemblyLinearVelocity = Vector3.new(0,0,0) -- Freeze the player in the air
workspace.Gravity = 0 -- Temporaly remove gravity (linear dash effect)
for i = DashTime * 20, -1, -1 do -- For the time give (put DashTime = 0 to be instant)
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y)) -- here we apply the velocity to the root part
task.wait(1/20)
end
workspace.Gravity = Gravity -- puts normal gravity back
task.wait(CooldownTime)
Cooldown = false
print("Good to go")
end
end

CAS:BindAction("Dash",Dash,Enum.KeyCode.G)
-- if you need to unbind the action use CAS:UnbindAction("Dash")
0 ups, 2y
I went quite creative with the dash mechanic so modify and tweak as you please !
0 ups, 2y,
1 reply
damn, tysm

problem is that it failed, but it’s probably my fault on that part:

I could see it working 100% better than what I could come up with
0 ups, 2y,
1 reply
Put this part in comment and test it.
It should work now !
(You just have to fix whatever script.Dash is...)
0 ups, 2y,
1 reply
one small issue: idfk exactly what “script.dash” really is
0 ups, 2y,
1 reply
I mean, I do get the gist of what it is but not the exact thing
but I’m still a dumdum retartar on coding so what do I know? ¯\_(ツ)_/¯
0 ups, 2y,
2 replies
Maybe it was supposed to be an animation, idk.
There's not many :Play() Method except TweenService and AnimationTrack...
But you can delete it, it would still work !
And if you figure it out, you can put it back.
0 ups, 2y,
2 replies
still didn’t work :(

I think the “script.Dash:Play()” might be important cuz it’s mentioned in an earlier line:

esp. if it’s mentioned in a function
0 ups, 2y
No it's not at all. I removed it when I tested the dash and put it back because I thought you had a use to it (._.)
0 ups, 2y,
1 reply
OH I KNOW.
Where did you put the script exactly?
0 ups, 2y,
1 reply
uh, put it as a localscript on startercharacterscripts?
0 ups, 2y
Ah so it's not that...
0 ups, 2y,
1 reply
or I could be dumb cuz it’s not in the UIS version but it’s present in the CAS version
0 ups, 2y
Wait can you paste the error please? It may be totally something else.
Or it doesn't show anything ?

(Also use only one or the the other)
0 ups, 2y,
1 reply
also I have another question

in the CAS script, it didn’t really specify which key to press to, basically activate everything. it only said “Enum.UserInputState.Begin”
How does it know which key will activate it?

or am I just dumb & I have to bind it myself instead of straight up copypaste the script. yet again, both scripts didn’t work somehow so why is that?
0 ups, 2y,
1 reply
At the end you got :
CAS:BindAction("Dash",Dash,Enum.KeyCode.G)

What this method does is simple :
- gives a name to your action ("Dash")
- link the action to a function (Dash function)
- check what key(s) you want to link the function

You can put multiple keys at the end, in this case I've just put the Enum.Keycode.G

And it still doesn't work? Can you paste the error here ?
0 ups, 2y,
1 reply
I forgor the last part 💀
.
.
.
.
.
.
.
.
.
.
.
.
.
spoiler: still didn’t work :/

no red lines appeared anywhere so I’m not sure what to put here
0 ups, 2y,
2 replies
And no errors in the console ?
0 ups, 2y
this is what i got:
0 ups, 2y,
1 reply
this one for the UIS version:
0 ups, 2y,
6 replies
YOO, i got it to work (uis version anyway).
somehow the script.dash broke everything there so i removed it

I managed to tweak it slightly to suit my needs and damn, it works really well
ofc, it isnt perfect
improvements that could be made:

1. i tweaked the ApplyImpulse(Vector3.new(0,2000,0) to ApplyImpulse(Vector3.new(0,0,0)
it removes the small upward motion before the dash but it prevents the dash from being used on the ground. (removes delay + a lot smoother in general)
Q. Should we maybe we could set the ground to frictionless or make a "else" statement to increase walkspeed instead if the player is touching the ground?

2. theres a small ramp up in speed during dashing. not really a big deal
Q. is there a way to make the dashing speed more consistent and instant (or remove the ramp up)?

3. there are other improvements that isnt directly related to the code but thats for another day
0 ups, 2y,
1 reply
R1 : Totally possible to do both, and because it's client sided it won't affect other players.
R2 : You could put the AssemblyLinearVelocity to 0 or a small number to stop the inertia.
And I'm happy it worked out ! Please to be useful.

If you have any other questions or requests, don't hesitate to ask me !
0 ups, 2y,
2 replies
forgot to ask:

4. Q. Is there a good way to change CharacterOrientation to something like MoveDirection?
It’d be better if the dash direction is based on movement direction (WASD) instead of look direction

5. Q. whats a good way to conserve momentum?
don’t really know how to word it that well so I’ll just put this here:


thanks anyway
0 ups, 2y,
1 reply
4R :
You can just change the orientation of the dash depending on the current character input.

The line is :
local CharacterOrientation = math.rad(HumanoidPart.Orientation.Y - 180)

The thing to change is the - 180 at the end.
For example, putting - 0 when the player press S will make the impulse go backwards.

5R :
For this specific question, you can give a small impulse on the root part (just like the dash) when the player jump (or constantly if you like) to add a bit of inertia to the player.
It will inevitably make him faster, but it should create momentum.

I didn't test my idea and will probably test it at home in 2-3h. I'll tell you the results!
0 ups, 2y
4R:
so, from what im getting here is that i can change the Y value to suit its direction (0 for S,90,180,270)?
i could probably do a script structure, something like:
< theres probably a better way to do this
the general idea is that W = dash forward, A = dash left, etc...

5R.
could try that. btw this also looks interesting enough to try:
AirController
0 ups, 2y
Also yeah you can use MoveDirection for the dash my bad
0 ups, 2y,
2 replies
That's weird.
On my side I don't get any of those problems :
- When I dash, I can't change direction, even if I input any key.
- My leg are perfectly on the ground, and it should've been possible to configure it via the GroundController.GroundOffset (you don't have to set it in negative, just change the value slightly between 2 and 3 should do the work)

1Q : are you talking about the dash or something else for the momentum ?
2Q : do you have all the 3 scripts in the good place ?
0 ups, 2y
Q1: i meant while in the air. when I launched myself forward by dashing then jumping afterwards, it’s fine. when I input any WASD during that airtime, I slowed down. the dash itself is perfect
Q2: the dash script is a local script in startercharacterscripts, along with the controller-based one. The initialising one is in serverscriptservice
0 ups, 2y,
1 reply
nvm, i somehow fixed the leg clipping issue by playing around with the jumpimpulse
.
.
.
.
.
.
.
.
.
.
.
.
.
still have the on-air movement key issue
0 ups, 2y,
1 reply
Sorry for not posting lately.
I somehow can't get ahead of my school work (my fault probably) so I have alot of things to do this week.
I'll come back to that later ✨️👍✨️
0 ups, 2y
take as much as rest as you need. i can wait for the next reply

in my awful attempt to fix it:
i tried adding an impulse every second to try to conserve the momentum whenever im pressing WASD while in the air. well, it did work at first but it doubled the force every second so i'll go zooming off next second. i just inserted this ungodly inefficient script at the end of the function:

while Enum.HumanStateType.FreeFalling and Enum.KeyCode.W or Enum.KeyCode.A or Enum.KeyCode.S or Enum.KeyCode.D do
local DashVelocity = Vector2.new(Humanoid.MoveDirection.X,Humanoid.MoveDirection.Z) * 100
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y))
task.wait(0.5) --avoids lag
local DashVelocity = Vector2.new(Humanoid.MoveDirection.X,Humanoid.MoveDirection.Z) / 100 --attempted to cancel out the first one
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y))
end
0 ups, 2y,
1 reply
NEW DASH SCRIPT (v3) (hehe version counter goes brrrr)

I'm gonna have to paste it in two part because it's too long for a simple Imgflig message.
I've put WAY more player setting and fixed the gravity problem (which I disabled last time).
I couldn't find the issue with "inputting any movement keys will significantly decelerate the player", so... I hope it works now ? Idk tell me if something goes wrong.

Last thing, you shouold try to do an indicator for the player when he can dash again (if you haven't done it already) as a GUI for example. If you need help with that don't mind to ask me (my game is essencially GUI's so I'm an expert at this point), but I'll recommand you to try it youself, as it is WAY less complicated than this.

------------------------------------

local CAS = game:GetService('ContextActionService')
local Player = game:GetService('Players').LocalPlayer
repeat task.wait() until Player.Character
local Character = Player.Character
local HumanoidPart = Player.Character:WaitForChild("HumanoidRootPart") -- Find the Root Part of the Character
local Humanoid = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid of the Character
local ControllerManager = Player.Character:WaitForChild("ControllerManager") -- Find the ControllerManager of the Character
local Gravity = workspace.Gravity

local AirController = ControllerManager.AirController
local GroundController = ControllerManager.GroundController
local SwimController = ControllerManager.SwimController
local ClimbController = ControllerManager.ClimbController

-- Modified the variables a bit so it worked properly
local Amount = 1000 -- Dash force
local DashTime = 0.25 -- Time the dash effect apply
local CooldownTime = 2 -- Cooldown Time
local Cooldown = false -- Cooldown Lock
0 ups, 2y,
1 reply
local function Dash(actionName, inputState, inputObject)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin and Cooldown == false then
Cooldown = true -- I prefer to always put the variable lock on top
local CharacterOrientation = math.rad(HumanoidPart.Orientation.Y - 180) -- Find the orientation of the humanoid
-- It was backward for some reason so I just subtract 180 degres
local DashVelocity = Vector2.new(Humanoid.MoveDirection.X,Humanoid.MoveDirection.Z) * Amount -- Actually, the Humanoid.MoveDirection works... sorry
if Humanoid.MoveDirection.Magnitude == 0 then
DashVelocity = Vector2.new(
math.sin(CharacterOrientation),
math.cos(CharacterOrientation)) * Amount
end

GroundController.Friction = 0 -- removes friction on ground
HumanoidPart.AssemblyLinearVelocity = Vector3.new(0,0,0) -- Freeze the player in the air
local JumpPower = ControllerManager:GetAttribute("JumpImpulse")
workspace.Gravity = 0 -- Temporaly remove gravity (linear dash effect)
ControllerManager:SetAttribute("JumpImpulse", Vector3.new(0,0,0)) -- basically remove jump ability when dashing so you can't just fly off in 0 gravity
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y)) -- one time impulse is way smoother
task.wait(DashTime)

workspace.Gravity = Gravity -- puts normal gravity back
GroundController.Friction = 2 -- puts normal friction
ControllerManager:SetAttribute("JumpImpulse", JumpPower) -- gives back jump ability
task.wait(CooldownTime)
Cooldown = false
print("Dash cooldown over")
end
end

--while wait(1) do print(Humanoid.MoveDirection) end
CAS:BindAction("Dash",Dash,true,Enum.KeyCode.F)
-- if you need to unbind the action use CAS:UnbindAction("Dash")
0 ups, 2y,
1 reply
---- nvm it took 3 messages TwT

-- Player settings :
wait()
--Instance.new("GroundController")
--Instance.new("AirController")

GroundController.AccelerationTime= 0 -- time player takes to move at max speed
GroundController.DecelerationTime = 0.35 -- time player takes to decelerate completely

ControllerManager:SetAttribute("JumpImpulse", Vector3.new(0,700,0)) -- jump height
GroundController.GroundOffset = 2.194 -- player's height. if the player's legs goes trought the ground, modify this.
GroundController.TurnSpeedFactor = 1 -- factor of the time the player takes to turn around
GroundController.Friction = 2 -- friction factor

GroundController.MoveSpeedFactor = 1 -- factor of speed when on the ground
AirController.MoveSpeedFactor = 1.25 -- factor of speed when in the air
ClimbController.MoveSpeedFactor = 0.9 -- factor of speed when climbing
SwimController.MoveSpeedFactor = 0.95 -- factor of speed when swimming
-- the rest ask me :D
0 ups, 2y
well, thats one issue fixed

i think i didnt word the movement key issue correctly. basically if u input any WASD movement, u practically lose all velocity or momentum, essentially stopping midair

also, still have problems with leg collisions:
< changing ground offset only determines the bounciness of each landing (positive gives higher bounces, negative does the opposite)
0 ups, 2y,
1 reply
so yeah WAYYY more stuff to add. If you have any question, don't hesitate.
(aalso I didn't check in details the 2 scripts distributed by the dev, you can do if you wants)

(+ If you just want to download yourself the 2 last scripts, go here : https://devforum.roblox.com/t/releasing-character-physics-controllers/2623426 )
1 up, 2y,
1 reply
got damn !!!1!!11 it works extremely well

i do have this one small issue where the legs clips into the ground but it says that it can be configured (only the humanoidrootpart & torso have collisions)
0 ups, 2y,
1 reply
nvm, there are other issues:

>inputting any movement keys will significantly decelerate the player
an issue if u want to change direction (esp. key A & D)

>dashing when not using any movement key will stop the player
probably derives from MoveDirection. wouldnt be great if you abruptly stopped midair. would be ideal if the default dash direction is forward
0 ups, 2y
Checking all of that rn !
0 ups, 2y,
1 reply
NEW SCRIPT FOR THE CAS :

I checked the script to make AirControl works and... it's complicated.
So I just downloaded the scripts disctributed by roblox lol (and tweaked them a littl bit).
Like I said, it will changes the character's physics, allowing it to be way more customisable.

So, here's the dash script :

local CAS = game:GetService('ContextActionService')
local Player = game:GetService('Players').LocalPlayer
repeat task.wait() until Player.Character
local Character = Player.Character
local HumanoidPart = Player.Character:WaitForChild("HumanoidRootPart") -- Find the Root Part of the Character
local Humanoid = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid of the Character
local ControllerManager = Player.Character:WaitForChild("ControllerManager") -- Find the ControllerManager of the Character
local Gravity = workspace.Gravity

local AirController = ControllerManager.AirController
local GroundController = ControllerManager.GroundController

-- Modified the variables a bit so it worked properly
local Amount = 1000 -- Dash force
local DashTime = 0.25 -- Time the dash effect apply
local CooldownTime = 2 -- Cooldown Time
local Cooldown = false -- Cooldown Lock

local function Dash(actionName, inputState, inputObject)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin and Cooldown == false then
Cooldown = true -- I prefer to always put the variable lock on top
local CharacterOrientation = math.rad(HumanoidPart.Orientation.Y - 180) -- Find the orientation of the humanoid
-- It was backward for some reason so I just subtract 180 degres
local DashVelocity = Vector2.new(Humanoid.MoveDirection.X,Humanoid.MoveDirection.Z) * Amount -- Actually, the Humanoid.MoveDirection works... sorry !

GroundController.Friction = 0 -- removes friction on ground
HumanoidPart.AssemblyLinearVelocity = Vector3.new(0,0,0) -- Freeze the player in the air
--workspace.Gravity = 0 -- Temporaly remove gravity (linear dash effect)
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y)) -- one time impulse is way smoother
task.wait(DashTime)

workspace.Gravity = Gravity -- puts normal gravity back
GroundController.Friction = 2 -- puts normal friction
task.wait(CooldownTime)
Cooldown = false
print("Good to go")
end
end

--while wait(1) do print(Humanoid.MoveDirection) end
CAS:BindAction("Dash",Dash,true,Enum.KeyCode.F)
-- if you need to unbind the action use CAS:UnbindAction("Dash")

-- Player settings :
0 ups, 2y,
1 reply
Here is the inicializing script (put it in a sever script in ServerScriptService) :

-- Replace Humanoid physics with a ControllerManager when a character loads into the workspace

local Players = game:GetService("Players")

function initialize(character)

local cm = Instance.new("ControllerManager")
local gc = Instance.new("GroundController", cm)
Instance.new("AirController", cm)
Instance.new("ClimbController", cm)
Instance.new("SwimController", cm)

local humanoid = character.Humanoid
cm.RootPart = humanoid.RootPart
gc.GroundOffset = humanoid.HipHeight
cm.FacingDirection = cm.RootPart.CFrame.LookVector

local floorSensor = Instance.new("ControllerPartSensor")
floorSensor.SensorMode = Enum.SensorMode.Floor
floorSensor.SearchDistance = gc.GroundOffset + 0.5
floorSensor.Name = "GroundSensor"

local ladderSensor = Instance.new("ControllerPartSensor")
ladderSensor.SensorMode = Enum.SensorMode.Ladder
ladderSensor.SearchDistance = 1.5
ladderSensor.Name = "ClimbSensor"

local waterSensor = Instance.new("BuoyancySensor")

cm.GroundSensor = floorSensor
cm.ClimbSensor = ladderSensor

waterSensor.Parent = cm.RootPart
floorSensor.Parent = cm.RootPart
ladderSensor.Parent = cm.RootPart
cm.Parent = character

end

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.EvaluateStateMachine = false -- Disable Humanoid state machine and physics
wait() -- ensure post-load Humanoid computations are complete (such as hip height)
initialize(character)
end)
end)
0 ups, 2y,
1 reply
And here's another local script to put in StarterCharacterScripts :

-- A simple state machine implementation for hooking a ControllerManager to a Humanoid.
-- Runs an update function on the PreAnimate event that sets ControllerManager movement inputs
-- and checks for state transition events.
-- Creates a Jump action and "JumpImpulse" attribute on the ControllerManager.

local rs = game:GetService("RunService")
local cas = game:GetService("ContextActionService")

local character = script.Parent
local cm = character:WaitForChild("ControllerManager")
local humanoid = character:WaitForChild("Humanoid")

-- Returns true if the controller is assigned, in world, and being simulated
local function isControllerActive(controller : ControllerBase)
return cm.ActiveController == controller and controller.Active
end

-- Returns true if the Buoyancy sensor detects the root part is submerged in water, and we aren't already swimming
local function checkSwimmingState()
return character.HumanoidRootPart.BuoyancySensor.TouchingSurface and humanoid:GetState() ~= Enum.HumanoidStateType.Swimming
end

-- Returns true if neither the GroundSensor or ClimbSensor found a Part and, we don't have the AirController active.
local function checkFreefallState()
return (cm.GroundSensor.SensedPart == nil and cm.ClimbSensor.SensedPart == nil
and not (isControllerActive(cm.AirController) or character.HumanoidRootPart.BuoyancySensor.TouchingSurface))
or humanoid:GetState() == Enum.HumanoidStateType.Jumping
end

-- Returns true if the GroundSensor found a Part, we don't have the GroundController active, and we didn't just Jump
local function checkRunningState()
return cm.GroundSensor.SensedPart ~= nil and not isControllerActive(cm.GroundController)
and humanoid:GetState() ~= Enum.HumanoidStateType.Jumping
end

-- Returns true of the ClimbSensor found a Part and we don't have the ClimbController active.
local function checkClimbingState()
return cm.ClimbSensor.SensedPart ~= nil and not isControllerActive(cm.ClimbController)
end

-- but wait, there's more !
0 ups, 2y
-- The Controller determines the type of locomotion and physics behavior
-- Setting the humanoid state is just so animations will play, not required
local function updateStateAndActiveController()
if checkSwimmingState() then
cm.ActiveController = cm.SwimController
humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
elseif checkClimbingState() then
cm.ActiveController = cm.ClimbController
humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
elseif checkRunningState() then
cm.ActiveController = cm.GroundController
humanoid:ChangeState(Enum.HumanoidStateType.Running)
elseif checkFreefallState() then
cm.ActiveController = cm.AirController
humanoid:ChangeState(Enum.HumanoidStateType.Freefall)
end
end

-- Take player input from Humanoid and apply directly to the ControllerManager.
local function updateMovementDirection()
local dir = character.Humanoid.MoveDirection
cm.MovingDirection = dir

if dir.Magnitude > 0 then
cm.FacingDirection = dir
else

if isControllerActive(cm.SwimController) then
cm.FacingDirection = cm.RootPart.CFrame.UpVector
else
cm.FacingDirection = cm.RootPart.CFrame.LookVector
end
end

end

-- Manage attribute for configuring Jump power
cm:SetAttribute("JumpImpulse", Vector3.new(0,700,0)) -- HERE jump height

-- Jump input
local IsJumping = false
local function doJump(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
IsJumping = true
elseif inputState == Enum.UserInputState.End then
IsJumping = false
end

while IsJumping do
if isControllerActive(cm.GroundController) then
local jumpImpulse = cm:GetAttribute("JumpImpulse")
cm.RootPart:ApplyImpulse(jumpImpulse)

character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
cm.ActiveController = cm.AirController

-- floor receives equal and opposite force
local floor = cm.GroundSensor.SensedPart
if floor then
floor:ApplyImpulseAtPosition(-jumpImpulse, cm.GroundSensor.HitFrame.Position)
end
end
repeat wait() until not(IsJumping) or isControllerActive(cm.GroundController)
end


end
cas:BindAction("Jump", doJump, true, Enum.KeyCode.Space)

--------------------------------
-- Main character update loop --
local function stepController(t, dt)

updateMovementDirection()

updateStateAndActiveController()

end
rs.PreAnimation:Connect(stepController)
0 ups, 2y
Soo

- I fixed the CAS script
- I check AirController and such and this is HUGE. It basically rewrite the Humanoid physics, but I'm giving is a try
0 ups, 2y,
1 reply
Ok the first version with UserInputService is :

local Debris = game:GetService('Debris')
local UIS = game:GetService('UserInputService')
local Player = game:GetService('Players').LocalPlayer
repeat task.wait() until Player.Character
local Character = Player.Character
local HumanoidPart = Player.Character:WaitForChild("HumanoidRootPart") -- Find the Root Part of the Character
local Humanoid = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid of the Character
local Gravity = workspace.Gravity

-- Modified the variables a bit so it worked properly
local DashTime = 0.2 -- Time the force apply
local Amount = 400 -- Dash force
local MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local P = 1250
local Cooldown = false -- Cooldown Lock
local CooldownTime = 2 -- Cooldown Time

UIS.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if not(gameProcessedEvent) and input.KeyCode == Enum.KeyCode.G and Cooldown == false then
Cooldown = true -- I prefer to always put the variable lock on top
local CharacterOrientation = math.rad(HumanoidPart.Orientation.Y - 180) -- Find the orientation of it
-- It was backward for some reason so I just subtract 180 degres
local DashVelocity = Vector2.new(
math.sin(CharacterOrientation),
math.cos(CharacterOrientation)) * Amount -- With a little bit of math, there is the dash velocity stored in a vector 2
script.Dash:Play() --I don't have the script.Dash so I trust you on that one
if Humanoid.FloorMaterial ~= Enum.Material.Air then
HumanoidPart:ApplyImpulse(Vector3.new(0,2000,0)) -- Makes the character airborn
wait()
end
HumanoidPart.AssemblyLinearVelocity = Vector3.new(0,0,0) -- Freeze the player in the air
workspace.Gravity = 0 -- Temporaly remove gravity (linear dash effect)
for i = DashTime * 20, -1, -1 do -- For the time give (put DashTime = 0 to be instant)
HumanoidPart:ApplyImpulse(Vector3.new(DashVelocity.X,0,DashVelocity.Y)) -- here we apply the velocity to the root part
task.wait(1/20)
end
workspace.Gravity = Gravity -- puts normal gravity back
task.wait(CooldownTime)
Cooldown = false
print("Good to go")
end
end)
0 ups, 2y
Put alot of comments here so you aren't lost
Created with the Imgflip Meme Generator
IMAGE DESCRIPTION:
IVY; I GOCHU SCRIPT