I have this dash/roll script and it’s not working at all. Hoping someone can review it and tell me what’s wrong. It doesn’t work at all, doesn’t move the character and it doesn’t play the animation.
local plr = game.Players.LocalPlayer
local Character = plr.CharacterAdded:wait()
local UIS = game:GetService("UserInputService")
local Mouse = plr:GetMouse()
local Debounce = true
local humanoid = Character:WaitForChild("Humanoid")
local anim1= script.Animation1
local Anim1 = humanoid:LoadAnimation(anim1) -- forward
local anim2= script.Animation2
local Anim2 = humanoid:LoadAnimation(anim2) -- right
local anim3= script.Animation3
local Anim3 = humanoid:LoadAnimation(anim3) -- left
local anim4= script.Animation4
local Anim4 = humanoid:LoadAnimation(anim4) -- back
local cd = 1 -- cooldown after the dash
local Sound = script:WaitForChild("Sound")
KeysDown={}
EE = script.SF.Value
local EiEi = 1
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
if EiEi == 1 then
EE = true
EiEi = 2
print(1)
elseif EiEi == 2 then
EE = false
print(2)
EiEi = 1
end
end
end)
local jump = 50 -- replace this with your actual jump power/jump height (set at default jump power right now)
UIS.InputBegan:Connect(function(Input,Dash)
if Dash then return end
if Input.KeyCode == Enum.KeyCode.Q and Debounce == true then
print("Dash")
Debounce = false
if KeysDown.W and EE == true then
Anim1:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.A and EE == true then
Anim2:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.RightVector * -75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.D and EE == true then
Anim3:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.RightVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.S and EE == true then
Anim4:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * -75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
end
-----------------------------------------------------------------------
if KeysDown.W and EE == false then
Anim1:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.A and EE == false then
Anim1:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.D and EE == false then
Anim1:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
elseif KeysDown.S and EE == false then
Anim1:Play()
humanoid.JumpPower = 0 -- replace with JumpHeight if that is ur game settings
local sol = game.ReplicatedStorage.DashEffect:Clone()
sol.Parent = workspace
sol.Anchored = true
sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 75 -- distance for dash
Sound:Play()
for i = 1,5 do
wait(0.001)
sol.Size = sol.Size + Vector3.new(1,1,1)
end
BV:Destroy()
wait(0.2)
sol:Destroy()
end
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
humanoid.JumpPower = jump
wait(cd) -- cooldown
Debounce = true
else
KeysDown[Input.KeyCode.Name]=true
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
KeysDown[input.KeyCode.Name] = nil
end
end)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
local localScript = script
local function reloadScript()
local newScript = localScript:Clone()
newScript.Parent = localScript.Parent
wait(0.1)
localScript:Destroy()
end
local function onCharacterAdded()
reloadScript()
end
wait (0.5)
plr.CharacterAdded:Connect(onCharacterAdded)
wait (0.5)