-
What do you want to achieve? I want to make a dash (dodge) system that if you press S and the dash key at the same time you dash back, but if you just press the dash key you go forward.
-
What is the issue? The script only detects when the player press the dash key and not the S + dash key.
-
What solutions have you tried so far? I looked and searched on DevForum but I didn’t find a solution.
Video showing the issue:
robloxapp-20220713-0023164.wmv (1.2 MB)
Script below:
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local UIS = game:GetService("UserInputService")
local Debounce = false
local keybind = player:WaitForChild("Config").Dash
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://8492933955"
local playAnim = humanoid:LoadAnimation(anim)
UIS.InputBegan:Connect(function(key, IsTyping)
if IsTyping then
return
else
if UIS:IsKeyDown(Enum.KeyCode[keybind.Value]) then
if Debounce == false then
if script.Parent.Parent.Parent.PlayerValues.Stunned.Value == false then
local State = player.Character.Humanoid:GetState()
if State == ("Enum.HumanoidStateType.Dead") then
return
else
Debounce = true
playAnim:Play()
local Sortear = math.random(1,3)
if Sortear == 1 then
script.Sound.PitchShiftSoundEffect.Enabled = false
script.Sound:Play()
elseif Sortear == 2 then
script.Sound.PitchShiftSoundEffect.Octave = 1.05
script.Sound.PitchShiftSoundEffect.Enabled = true
script.Sound:Play()
elseif Sortear == 3 then
script.Sound.PitchShiftSoundEffect.Octave = 1.1
script.Sound.PitchShiftSoundEffect.Enabled = true
script.Sound:Play()
end
player.Character.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 135
local cd = script:WaitForChild("Dash"):Clone()
cd.Parent = script.Parent.Parent.Parent.RightFoot
cd:Emit(10)
cd.Enabled = true
spawn(function()
wait(0.5)
cd.Enabled = false
cd:Destroy()
end)
wait(3)
playAnim:Stop()
Debounce = false
end
end
end
elseif UIS:IsKeyDown(Enum.KeyCode[keybind.Value]) and UIS:IsKeyDown(Enum.KeyCode.S) then
if Debounce == false then
if script.Parent.Parent.Parent.PlayerValues.Stunned.Value == false then
local State = player.Character.Humanoid:GetState()
if State == ("Enum.HumanoidStateType.Dead") then
return
else
Debounce = true
playAnim:Play()
local Sortear = math.random(1,3)
if Sortear == 1 then
script.Sound.PitchShiftSoundEffect.Enabled = false
script.Sound:Play()
elseif Sortear == 2 then
script.Sound.PitchShiftSoundEffect.Octave = 1.05
script.Sound.PitchShiftSoundEffect.Enabled = true
script.Sound:Play()
elseif Sortear == 3 then
script.Sound.PitchShiftSoundEffect.Octave = 1.1
script.Sound.PitchShiftSoundEffect.Enabled = true
script.Sound:Play()
end
player.Character.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * -135
local cd = script:WaitForChild("Dash"):Clone()
cd.Parent = script.Parent.Parent.Parent.RightFoot
cd:Emit(10)
cd.Enabled = true
spawn(function()
wait(0.5)
cd.Enabled = false
cd:Destroy()
end)
wait(3)
playAnim:Stop()
Debounce = false
end
end
end
end
end
end)