#Improper stun reset?
1 messages · Page 1 of 1 (latest)
look at your else statements
they dont make sense
do
if -- then
elseif then
else
end
and so on
really? It seemed to work fine for me, maybe the structure is just funky. Unless it is wrong.
it technically can work like that but its just not quite optimal i guess?
it just makes it sloppy n shi
yea probably is not optimal, im not well versed in lua
** You are now Level 1! **
Though do u happen to know how to have only 1 stun timer per event?
oh uhh lemme see but i messed with your script a bit
local KickEvent = game.ReplicatedStorage:WaitForChild("Kick")
local debris = game:GetService("Debris")
local dmg
local force
local upward
local stuntimer = 2
local function pushback(plrhrp, hrp, pushforce, upward)
local bv = Instance.new("BodyVelocity")
bv.P = 2000
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = plrhrp.CFrame.LookVector * pushforce + Vector3.new(0, upward, 0)
bv.Parent = hrp
debris:AddItem(bv, 0.4)
end
KickEvent.OnServerEvent:Connect(function(plr, victim, combo)
local victimchar = victim.Parent
local victimhrp = victimchar:WaitForChild("HumanoidRootPart")
local plrchar = plr.Character
local plrhrp = plrchar:WaitForChild("HumanoidRootPart")
task.spawn(function()
while true do
stuntimer -= 0.1
if stuntimer >= 0 then
victimchar:SetAttribute("Stunned", true)
print("stunned")
else
victimchar:SetAttribute("Stunned", false)
print("Not Stunned")
stuntimer = 2
break
end
wait(0.1)
end
end)
-- Blocking check
if victimchar:GetAttribute("Blocking") == true then
combo = 3
force = 50
upward = 15
stuntimer = 2
pushback(plrhrp, victimhrp, force, upward)
victimchar:SetAttribute("Blocking", false)
elseif combo == 3 then
force = 50
upward = 15
pushback(plrhrp, victimhrp, force, upward)
stuntimer = 2
else
force = 5
upward = 0
pushback(plrhrp, victimhrp, force, upward)
stuntimer = 2
victimchar:TakeDamage(10)
end
end)
for a timer you can use time()
and then like
time - 0 < coolDownTime or something idfk
and then updated time = time()
¯_(ツ)_/¯
wait im slow sorry
ok ty, I'll try time(), I knew it was probably the better way to go than the way I did but I don't know how to implement it yet so I thought making a variable go down like that would suffice lol
ill show an actuall example of cooldown i used (using time) if u want
Cooldown thing i think, would u like to see the client code? Also yea an example would be nice
aight sec
local coolDown = 0.7
local lastSlashTime = 0
bulletEventConnection = shootBullet.OnClientEvent:Connect(function()
local currentTime = time()
local withinCooldown = currentTime - lastSlashTime < coolDown
lastSlashTime = currentTime
if withinCooldown then
slash1 = not slash1
else
slash1 = false
end
this is just a snippet of something
K ima analyze for a sec cause my brain going blank lol
okay : D
If the time (seconds) since the last action is less than cooldown, then do blah blah
does the if statement for withincooldown always make slash1 false?
you can ignore that
think abt like this
if within cooldown then (in your case) do nothing?
probably by using a debounce
srry, Im still trying to grasp the logic behind the timing
"if cooldown passed then can do ActionDebounce = true" that kinda logic
currentTime - lastSlashTime < coolDown
^^secondsPassed-lastAction(in seconds) lessThan coolDown time
good luck 
i hope i didnt confuse you 💔