SO my attack stuns when the stun() function is used. The only issue is that when i attack again, it doesn’t really keep the stun.
So if i attack and the stun function is fired, then i attack again, the previous unstun function that has been fired will remove the stun from the player. Which allows the player to attack mid combo.
local function stun()
local dodge = {6826577436,6826580666,6826586009}
local num = math.random(#dodge)
local chosenanim = dodge[num]
local Track10= Instance.new("Animation")
Track10.AnimationId = "rbxassetid://"..chosenanim
game.Debris:AddItem(Track10, 2)
local Anim10 = chr.Humanoid:LoadAnimation(Track10)
Anim10:Play(.1,1,2)
chr.Disabled2.Value = true
end
local function unstun()
chr.Disabled2.Value = false
end
local function lol(num)
if dmg == 0 then return end
local a = Instance.new("BillboardGui", chr.HumanoidRootPart)
a.Size = UDim2.new(2.5, 0, 2.5, 0)
a.AlwaysOnTop = false
local rando = math.random(0,1)
local lolidk = 0.5
a.SizeOffset = Vector2.new(rando, lolidk +0.5)
local b = Instance.new("TextLabel", a)
b.BackgroundTransparency = 1
b.BorderSizePixel = 0
b.Size = UDim2.new(1, 0, 1, 0)
b.Font = "Arcade"
b.Text = num
b.TextScaled = true
b.TextColor3 = Color3.new(0.462745, 0.101961, 0.101961)
b.TextSize = 1
local tween = TweenService:Create(a, TweenInfo.new(2), {SizeOffset = Vector2.new(rando, lolidk +2)})
tween:Play()
tween = TweenService:Create(b, TweenInfo.new(1), {TextTransparency = 1})
tween:Play()
game.Debris:AddItem(a, 1)
game.Debris:AddItem(b, 1)
local volume = Instance.new("Sound")
volume.Pitch = pitch
volume.Volume = .5
volume.SoundId = soundid
volume.Parent = chr.Torso
game.Debris:AddItem(volume, 1)
volume:Play()
stun()
wait(stuntime)
unstun()
end
anyone know how i can fix this?