hello,
i was making an M1 system and i ran into an issue.
local UIS = game:GetService("UserInputService")
local attacknum = 0
local Mscript = script.Parent.testimgm1m
local debounce = false
local newtick = nil
local ticktime = nil
UIS.InputBegan:Connect(function(input, istyping)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not istyping and debounce == false then
--first punch
if attacknum == 0 then
debounce = true
require(Mscript).punch1()
wait(0.5)
debounce = false
ticktime = tick()
end
--timeout punch 2
elseif attacknum == 1 then
newtick = tick()
if newtick - ticktime > 1.5 then
debounce = true
require(Mscript).punch1()
attacknum = 0
wait(0.5)
debounce = false
ticktime = tick()
end
end
--timed punch 2
if attacknum == 1 then
newtick = tick()
if newtick - ticktime <= 1.5 then
debounce = true
require(Mscript).punch2()
attacknum = 2
wait(0.5)
debounce = false
ticktime = tick()
end
--timeout punch 3
elseif attacknum == 2 then
newtick = tick()
if newtick - ticktime > 1.5 then
debounce = true
require(Mscript).punch1()
attacknum = 0
wait(0.5)
debounce = false
ticktime = tick()
end
end
--timed punch 3
if attacknum == 2 then
newtick = tick()
if newtick - ticktime <= 1.5 then
debounce = true
require(Mscript).punch3()
attacknum = 3
wait(0.5)
debounce = false
ticktime = tick()
end
--timeout punch 4
elseif attacknum == 3 then
newtick = tick()
if newtick - ticktime > 1.5 then
debounce = true
require(Mscript).punch1()
attacknum = 0
wait(0.5)
debounce = false
ticktime = tick()
end
end
--timed punch 4
if attacknum == 3 then
newtick = tick()
if newtick - ticktime <= 1.5 then
debounce = true
require(Mscript).punch4()
attacknum = 0
wait(1)
debounce = false
end
end
end)
my script is designed to do a series of 4 punches, in a row. if you punch again, after the first punch, iwthin 1.5 seconds, it will go to the next punch. if you punch later than that, you go back to the first punch.
so, it will basicly just do the first punch over and over.
thats my problem. what am i doing wrong?