Hello everyone, a strange thing is happening to me. After the reset, the dash stops working, although, before the reset it works normally, the dash code is written in the module script in StarterCharacter and is called in the local script. I think the problem is in the module script. Help me, please! I will be very grateful for your help. Here is the module script:
repeat task.wait() until game.Players.LocalPlayer
local Tween = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
local Character = game.Players.LocalPlayer.Character
local IsOn, DashLenght, CoolDown = nil, 0.4, 0
local DashAnim = Character:WaitForChild("Humanoid"):LoadAnimation(RS:WaitForChild("Anim"):FindFirstChild("DashAnim"))
local DefaultView = 70
local DashSpeed = 40
local TrashTable = {}
local DashModule = {}
function DashModule.OnDash()
if IsOn then return end
IsOn = true
local BodyVel = Instance.new("BodyVelocity", Character:WaitForChild("HumanoidRootPart"))
BodyVel.MaxForce = Vector3.new(100000, 200, 100000)
BodyVel.Velocity = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * DashSpeed
TrashTable[Character] = BodyVel
DashAnim:Play()
script:WaitForChild("dash"):Play()
local InfoTween = TweenInfo.new(DashLenght, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, true)
Tween:Create(game.Workspace.CurrentCamera, InfoTween, {FieldOfView = DefaultView + 20}):Play()
task.wait(DashLenght)
DashAnim:Stop()
TrashTable[Character]:Destroy()
TrashTable[Character] = nil
task.wait(CoolDown)
IsOn = nil
end
return DashModule