This is a bit of code that I found on the devforum, I am just wondering why this person used a spawn section here? Any explanation will do, thanks!
local handle;
mouse.Button2Down:Connect(function()
if attacking == false and equipped == true then
-- Only run if not already running
if not handle then
local currentHandle = {}
handle = currentHandle
blocking = true
remoteEvent:FireServer("Block", true)
spawn(function()
-- Cancel if handle changed
if handle ~= currentHandle then return; end
remoteEvent:FireServer("Stun", true)
wait(2)
-- Cancel if handle changed
if handle ~= currentHandle then return; end
remoteEvent:FireServer("Stun", false)
-- Allow next attack
handle = nil
end)
CurrentBlockAnimation = block_Animations[math.random(1, #block_Animations)]
CurrentBlockAnimation:Play()
end
end
end)