So I have a weapon and I scripted it so if they are pressing “S” while swinging, they stop going back/moving back
However, right now, it does that but once the player stops swinging, they have to press S again to start moving back, rather, I want it so once they stop swinging (they can swing consecutively btw) they are able to start moving back
tes - Roblox Studio (gyazo.com)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and (humanoid.MoveDirection.Magnitude > 0) then
if block == false then -- not blocking
if sprintdebounce == false then
isRunning = true
Character.Humanoid.WalkSpeed = 34
PlayAnim:Play()
sprintdebounce = true
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if humanoid.WalkSpeed == 0 then
PlayAnim:Stop()
end
end)
end
end
elseif input.KeyCode == Enum.KeyCode.S and keybindCoolDown == false then
isPressingS = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if block == false then -- not blocking
if sprintdebounce == true and keybindCoolDown == false then
if equip == true then
--//Get Equip Speed
local getspeed = game.ReplicatedStorage.GameEvents.GetSpeedEquip:InvokeServer()
if getspeed then
Character:FindFirstChildOfClass("Humanoid").WalkSpeed = getspeed
end
else
Character.Humanoid.WalkSpeed = 16
end
isRunning = false
PlayAnim:Stop()
sprintdebounce = false
end
end
elseif input.KeyCode == Enum.KeyCode.S and keybindCoolDown == false then
isPressingS = false
if Character:FindFirstChildOfClass("Humanoid").WalkSpeed == 0 and block == false then
--// Get equip speed
local getspeed = game.ReplicatedStorage.GameEvents.GetSpeedEquip:InvokeServer()
if getspeed then
Character:FindFirstChildOfClass("Humanoid").WalkSpeed = getspeed
end
end
end
end)
--//this runs when a player left clicks
local function SwingFunction()
if swingDebounce == false then
camShake:Shake(CameraShaker.Presets.SwordHit)
swingDebounce = true
script.Parent.Cursor.Value = script.Parent.Configuration.DefaultCursor.Value
local success, speed = game.ReplicatedStorage.GameEvents.SwingEvent:InvokeServer(SwordOrder[currentSwing], isPressingS)
currentSwing = currentSwing + 1
if success == true then
if isPressingS == false then
Character:FindFirstChildOfClass("Humanoid").WalkSpeed = speed
elseif isPressingS == true then
Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 0
end
swingDebounce = false
end
end
end