1. What do you want to achieve?
Okay, i have this dash system in local script at StarterCharacteeScript and a tool in ReplicatedStorage with a server script with handle made with a union and a additional hitbox part.
2. What is the issue?
The issue happen when you decide to perform the tool attack and the dash in order and faster
I just don’t know how to stop one of these script while the other is doing the action.
3. What solutions have you tried so far?
Well… Debounce, bool value and disabling the local script.
I keept debounce and the bool value cause they make the code a bit understandable.
Actually the boolvalue seems to have fixed the opposite situation using manualactivationonly.
I don’t know this issue look like a sort of delay and my game has a lot of parts/unions. I tried on an empty place and is still the same.
I don’t think is a server/connection fault.
Inside the local script there is also a non-tool heal system that replicate and cframe a model in replicatedstorage to the character and works the same as the dash for the exception that is not a dash.
Even the heal key has the same issue as the dash when dealing with the tool script.
The server script’s tool(slash function):
--Sword Slash
script.Parent.Activated:Connect(function()
if not db then
db = true
if con.trailEnabled == true then
script.Parent.Handle.Trail.Enabled = true
end
local Dash = script.Parent.Parent:WaitForChild("Dash")
local Value = Dash:FindFirstChildOfClass("BoolValue")
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChildOfClass("Animator")
local hrp = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local BodyVelocity = Instance.new("BodyVelocity")
local BodyGyro = Instance.new("BodyGyro")
local effect = script.Parent.Handle.Spark
if not slash then
if randomSlash == 1 and Value.Value == false then
slash = animator:LoadAnimation(script.Slash1)
randomSlash = randomSlash + 1
humanoid.WalkSpeed = 8
humanoid.JumpPower = 0
delay(1.5, function()
if randomSlash == 2 then
randomSlash = 1
end
end)
elseif randomSlash == 2 and Value.Value == false then
BodyVelocity.Parent = script.Parent.Parent:WaitForChild("HumanoidRootPart")
BodyGyro.Parent = script.Parent.Parent:WaitForChild("HumanoidRootPart")
humanoid.AutoRotate = false
slash = animator:LoadAnimation(script.Slash2)
randomSlash = randomSlash - 1
humanoid.WalkSpeed = 8
humanoid.JumpPower = 0
effect.Enabled = true
BodyVelocity.MaxForce = Vector3.new(100000, 0, 100000)
BodyVelocity.P = 100000
BodyVelocity.Velocity = hrp.CFrame.LookVector * Vector3.new(30, 0, 30)
BodyGyro.MaxTorque = Vector3.new(400000,400000,400000)
BodyGyro.CFrame = hrp.CFrame
end
end
slash:Play()
wait(0.4)
script.Parent.Handle.Slash:Play()
wait(0.75)
if slash then
slash:Stop()
slash = nil
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
effect.Enabled = false
humanoid.AutoRotate = true
BodyVelocity:Destroy()
BodyGyro:Destroy()
end
script.Parent.Handle.Trail.Enabled = false
db = false
end
end)
the dash:
function ToolDetect()
for _, tool in pairs(Char:GetChildren()) do
if tool:IsA("Tool") then
tool.ManualActivationOnly = true
IsDashing.Value = true
print(tool.ManualActivationOnly, IsDashing.Value)
end
end
end
function ToolDetected()
for _, tool in pairs(Char:GetChildren()) do
if tool:IsA("Tool") then
tool.ManualActivationOnly = false
IsDashing.Value = false
print(tool.ManualActivationOnly, IsDashing.Value)
end
end
end
function EstusFlaskUsageZ()
local animator = Char.Humanoid:FindFirstChildOfClass("Animator")
if CanDrink then
CanDrink = false
IsDrinking.Value = true
ToolDetect()
game.ReplicatedStorage:WaitForChild("EstusDrinkEvent"):FireServer()
animator:LoadAnimation(script.EstusDrinkAnim):Play()
script.EstusDrink:Play()
task.wait(1)
IsDrinking.Value = false
task.wait(CoolDownEstus)
CanDrink = true
end
end
function velocityFunctionW()
local animator = Char.Humanoid:FindFirstChildOfClass("Animator")
if CanDash and Char.Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) and IsDrinking.Value == false then
CanDash = false
ToolDetect()
local BodyPosition = Instance.new("BodyPosition", Char.HumanoidRootPart)
local BodyGyro = Instance.new("BodyGyro", Char.HumanoidRootPart)
game.ReplicatedStorage.ForceFieldEvent:FireServer()
BodyPosition.MaxForce = Vector3.new(14000, 0, 14000)
BodyPosition.P = 14000
BodyPosition.D = 2000
BodyPosition.Position = (Char.HumanoidRootPart.CFrame * Vector3.new(0, 0, -30))
BodyPosition.Parent = Char.HumanoidRootPart
BodyGyro.MaxTorque = Vector3.new(400000,400000,400000)
BodyGyro.CFrame = Char.HumanoidRootPart.CFrame
animator:LoadAnimation(script.DashW):Play()
script.DashSound:Play()
Char.Humanoid.AutoRotate = false
task.wait(1)
ToolDetected()
BodyPosition:Destroy()
BodyGyro:Destroy()
Char.Humanoid.AutoRotate = true
task.wait(CoolDown)
CanDash = true
end
end
--bla bla bla (the script has even keybind for lateral dashes and mobile support with shiftlock but its not important now)
game:GetService("UserInputService").InputBegan:Connect(function(key, gameprocessed)
if gameprocessed then return end
if not IsDashing then return end
if not IsDrinking then return end
if key.KeyCode == KeyCodeQ and UIS:IsKeyDown(KeyCodeW) then
velocityFunctionW()
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(key, gameprocessed)
if gameprocessed then return end
if not IsDashing then return end
if not IsDrinking then return end
if key.KeyCode == KeyCodeZ then
EstusFlaskUsageZ()
end
end)
I’m really sorry for the wall text also for the bad english.