I've already asked 2 times before but i've gotten no help :/
I have made a combat system but the stun is super bad right now when you fire a remote event it fires with the number of seconds you want the target to be stunned but if im doing a combo it puts the stunned value to false and then they can attack again DURING the combo How can I make this more efficient and better??
local script fires the event
Damage:FireServer(hitbox,damage,knockback,stunseconds, punchsfx)
serverscript aka stun/damage script
local gothit = false game.ReplicatedStorage.Damage1.OnServerEvent:Connect(function(plr, part, damage, knockback, stun, sound) local chr = plr.Character local hitbox = game:GetService("ReplicatedStorage"):WaitForChild("Hitbox"):Clone() local weld = Instance.new("WeldConstraint") hitbox.Parent = workspace.Effects hitbox.CFrame = part.CFrame weld.Parent = hitbox weld.Part0 = hitbox weld.Part1 = part hitbox.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Stand") and hit.Parent:FindFirstChild("Hit") and hit.Parent:FindFirstChild("Stand") then gothit = true local bv = Instance.new("BodyVelocity") bv.MaxForce = Vector3.new(1e8,1e8,1e8) bv.P = math.huge bv.Velocity = chr.HumanoidRootPart.CFrame.lookVector * knockback bv.Parent = hit.Parent.HumanoidRootPart game.Debris:AddItem(bv,.3) hit.Parent.Humanoid:TakeDamage(damage) hit.Parent.Hit.Value = true hitbox:Destroy() wait(stun) hit.Parent.Hit.Value = false gothit = false end end) wait(0.5) if gothit == false then if gothit == false then hitbox:Destroy() end end end)