#best way to handle stunning people

1 messages · Page 1 of 1 (latest)

obtuse root
#

what would be the best way to handle stunning players for a certain amount of time? task.wait is being messy for me and unstunning when its not supposed to

#

not sure if this is the exact correct channel for this

#

mb if its not

granite basin
#

Show code

obtuse root
#

okay hold on

#

while its booting up

#

the problem is

#

is that lets say i have 2 waits

#

one wait may finish and unstun before the other wait is finished

#

meaning it unstuns when i dont want it to

#

which is obviously bad

#

okay let me get the code rq

granite basin
#

So why u stunning twice

obtuse root
#

cuz of other moves happening at the same time

#

like m1s

#

thats 4 stuns happening in quick succession

#
local module = {}

function module.Stun(char : Model, timecantunstun : number, timestun : number)
    char:SetAttribute("Stunned", true)
    char:SetAttribute("CanUnstun", false)
    task.wait(timecantunstun)
    char:SetAttribute("CanUnstun", true)
    task.wait(timestun)
    if char:GetAttribute("CanUnstun") == false then return end
    char:SetAttribute("Stunned", false)
end

return module

granite basin
obtuse root
#

whats that?

granite basin
#

With repeat untill rn is the unix

granite basin
#

Basically u can save time

obtuse root
#

so i should use repeat loops?

granite basin
#

I am thinking if not while loop with task wait wouldn't be better

As in
while true do
now = os.clock()
task.wait(stunned[plr]-now)
If stunned[plr] <= now then
Unstunne
End
end

obtuse root
#

okay ill try it out in a bit

granite basin
#

If u add stun time while stunned it should be fine

#

Shouldnt have the problem u got

obtuse root
#

alr ill log in here how this goes

obtuse root
granite basin
#

maybe smth like this

#

sorry for format but i wrote it on discord

obtuse root
granite basin