Hello! I just wanted to execute the following script.
except on the 4th elseif, even with all requirements, it does not work. here, (i put many comments on the error line)
[BTW, NO ERRORS IN OUTPUT]
this script makes 4 m1s.
on the 4th one it does not work
local plr = game.Players.LocalPlayer
local char = plr.Character
local count = 1
local mouse = plr:GetMouse()
local debounce = false
local oldtime
local newtime
mouse.Button1Down:Connect(function(IS)
local inactivefolder = char:FindFirstChild("InactiveWeapon")
local activefolder = char:FindFirstChild("ActiveWeapon")
if IS == true then return end -- check if plr isnt chatting
if debounce == true then return end
if activefolder:GetChildren()[1] then
if count == 1 then --if m1
print(count) --print m1
m1()
elseif count == 2 then --if m2
print(count) -- print m2
newtime = os.clock()
if newtime - oldtime <= 1.5 and newtime - oldtime >= 0.3 then
count = count + 1 -- m3
-- slash
if debounce == true then return end
debounce = true
plr.Character.Humanoid.WalkSpeed = 14
local animation = plr.Character.Humanoid:LoadAnimation(script.M2)
animation:Play()
--dash
local dash = Instance.new("BodyVelocity")
dash.MaxForce = Vector3.new(1,0,1) *30000
dash.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
dash.Parent = char.HumanoidRootPart
game.ReplicatedStorage.Events.Punch2:FireServer()
task.wait(0.2)
debounce = false
for i = 1, 8 do
task.wait(0.1)
dash.Velocity *= 0.15
end
dash:Destroy()
--oldtime
oldtime = os.clock()
plr.Character.Humanoid.WalkSpeed = 16
else
count = 1
m1()
end
elseif count == 3 then --if m2
print(count) -- print m2
newtime = os.clock()
if newtime - oldtime <= 1.5 and newtime - oldtime >= 0.3 then
count = count + 1 -- m3
-- slash
if debounce == true then return end
debounce = true
plr.Character.Humanoid.WalkSpeed = 14
local animation = plr.Character.Humanoid:LoadAnimation(script.M3)
animation:Play()
--dash
local dash = Instance.new("BodyVelocity")
dash.MaxForce = Vector3.new(1,0,1) *30000
dash.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
dash.Parent = char.HumanoidRootPart
game.ReplicatedStorage.Events.Punch2:FireServer()
task.wait(0.2)
debounce = false
for i = 1, 8 do
task.wait(0.05)
dash.Velocity *= 0.15
end
dash:Destroy()
--oldtime
oldtime = os.clock()
plr.Character.Humanoid.WalkSpeed = 16
print(count)
else
count = 1
m1()
end
end
elseif count == 4 then --if m4 -- Here's the 'error' even tho there arent any in the output
print("Number 4") -- maybe too many elseifs?
newtime = os.clock() -- the requirements are perfectly met.
if newtime - oldtime <= 1.5 and newtime - oldtime >= 0.3 then
count = 1 -- reset
-- slash
if debounce == true then return end
debounce = true
plr.Character.Humanoid.WalkSpeed = 14
local animation = plr.Character.Humanoid:LoadAnimation(script.M4)
animation:Play()
--dash
local dash = Instance.new("BodyVelocity")
dash.MaxForce = Vector3.new(1,0,1) *30000
dash.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
dash.Parent = char.HumanoidRootPart
game.ReplicatedStorage.Events.Punch2:FireServer()
task.wait(0.2)
debounce = false
for i = 1, 8 do
task.wait(0.1)
dash.Velocity *= 0.15
end
dash:Destroy()
--oldtime
oldtime = os.clock()
plr.Character.Humanoid.WalkSpeed = 16
else
count = 1
m1()
end
end
end)
function m1()
spawn(function()
task.wait(0.1)
if count == 1 then
count = count + 1
else
count = 1
end
debounce = true
plr.Character.Humanoid.WalkSpeed = 14
local animation = plr.Character.Humanoid:LoadAnimation(script.M1)
oldtime = os.clock()
animation:Play()
local dash = Instance.new("BodyVelocity")
dash.MaxForce = Vector3.new(1,0,1) *30000
dash.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
dash.Parent = char.HumanoidRootPart
game.ReplicatedStorage.Events.Punch1:FireServer()
debounce = false
for i = 1, 8 do
task.wait(0.1)
dash.Velocity *= 0.15
end
dash:Destroy()
oldtime = os.clock()
plr.Character.Humanoid.WalkSpeed = 16
end)
end