StunTime is basically a variable that sets the duration of the stun. When they’re blocking im setting it to 5 so i can have like a block break effect, but for some reason it returns to 1.
Here is my code. (Ill cut it so you can see more clearly whats happening.)
Hitbox.OnHit:Connect(function(hit, humanoid)
if humanoid.Parent.Name ~= script.Parent.Parent.Name then
local vel = Instance.new("BodyVelocity")
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
vel.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 30
vel.Name = "vel"
vel.Parent = hit
local brektrack = humanoid:LoadAnimation(brek)
print(humanoid.Parent:WaitForChild("StunTime").Value)
if humanoid.Parent.IsBlocking.Value == true then
print(humanoid.Parent:WaitForChild("StunTime").Value.." 1")
humanoid.Parent:WaitForChild("StunTime").Value = 5
print(humanoid.Parent:WaitForChild("StunTime").Value.." 2")
humanoid.Parent.stun.Value = true
humanoid.Parent.IsBlocking.Value = false
script.Parent.blockb:Play()
brektrack:Play()
wait(0.5)
vel:Destroy()
else
humanoid.Parent.stun.Value = true
end
print(humanoid.Parent:WaitForChild("StunTime").Value.." 3")
--7919154517
script.Parent.spp:Play()
humanoid:TakeDamage(15)
humanoid.Parent.HumanoidRootPart.Orientation = Character.HumanoidRootPart.Orientation + Vector3.new(0,180,0)
wait(humanoid.Parent.StunTime.Value)
vel:Destroy()
humanoid.Parent.stun.Value = false
humanoid.Parent:WaitForChild("StunTime").Value = 1
end
end)
wait(0.3)
body:Destroy()
wait(0.2)
Hitbox:HitStop()
wait(1)
db = false
if IsBlocking.Value == false then
Character.Humanoid.WalkSpeed = 16
end
wait(5)
spdb = false
end
end)