My script fires 3 times instead of a single time, I’ve tried debouncing and it still fires multiple times, and I’m not sure what causes this. Can anyone help?
dashevent.OnServerEvent:Connect(function(sender)
if pressedonce == false then
pressedonce = true
local char = sender.Character
local stamina = sender.Backpack.Stamina
if stamina.Value > 0 then
stamina.Value -= 1
print(stamina.Value)
local playAnim = char.Humanoid:LoadAnimation(dashanimation)
playAnim:Play()
print(sender,"dash")
local Attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
Attachment1.Name = "Attachment1"
Attachment1.Position = Vector3.new(0, 1.4, 0)
local Attachment = Instance.new("Attachment", char.HumanoidRootPart)
Attachment.Position = Vector3.new(0, -1.6, 0)
local TrailCloned = CloneTrail:Clone()
TrailCloned.Parent = char.HumanoidRootPart
TrailCloned.Attachment1 = Attachment1
TrailCloned.Attachment0 = Attachment
local SmokeClone = Smoke:Clone()
SmokeClone.Parent = char.HumanoidRootPart
local DashClone = DashNoise:Clone()
DashClone.Parent = char.HumanoidRootPart
DashClone:Play()
local SpindashClone = Spindash:Clone()
SpindashClone.Parent = char.HumanoidRootPart
SpindashClone:Play()
local Tween0 = TweenService:Create(char.Head.face, TweenStyle, {Transparency = 1})
Tween0:Play()
for i, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v ~= char:FindFirstChild("Humanoid").RootPart then
local Tween1 = TweenService:Create(v, TweenStyle, {Transparency = 1})
Tween1:Play()
elseif v:IsA("Accessory") then
local Tween2 = TweenService:Create(v:WaitForChild("Handle"), TweenStyle, {Transparency = 1})
Tween2:Play()
end
end
SmokeClone.Enabled = false
TrailCloned.Enabled = false
char.Humanoid.JumpPower = 50
for i, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v ~= char:FindFirstChild("Humanoid").RootPart then
local Tween3 = TweenService:Create(v, TweenStyle, {Transparency = 0})
Tween3:Play()
elseif v:IsA("Accessory") then
local Tween4 = TweenService:Create(v:WaitForChild("Handle"), TweenStyle, {Transparency = 0})
Tween4:Play()
end
end
local Tween10 = TweenService:Create(char.Head.face, TweenStyle, {Transparency = 0})
local playAnim1 = char.Humanoid:LoadAnimation(rollout)
playAnim:Play()
Tween10:Play()
playAnim:Stop()
wait(1)
SpindashClone:Destroy()
DashClone:Destroy()
TrailCloned:Destroy()
Attachment:Destroy()
Attachment1:Destroy()
SmokeClone:Destroy()
pressedonce = false
else
print("No stamina?")
end
end
end)