I would love if someone could explain to me what i did wrong in this script to make it cause lag to the server
-
What is the issue? Include screenshots / videos if possible!
local Human = game.Players.LocalPlayer
local char = Human.CharacterAdded:Wait()
local WeaponTool = script.Parent
local man = char:WaitForChild(“Humanoid”)
local idle = man:LoadAnimation(script:WaitForChild(“Equip”))
local M1 = man:LoadAnimation(script:WaitForChild(“m1”))
local M2 = man:LoadAnimation(script:WaitForChild(“m2”))
local M3 = man:LoadAnimation(script:WaitForChild(“m3”))
local M4 = man:LoadAnimation(script:WaitForChild(“m4”))
local bebe = false – Debounce
local combo = 0
local HitPlayer = {}
local DamageA = script.Script.RemoteEvent
local DamageC = script.M4.Lhit
local TUCR = 1.5
local LTC = tick()
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.BodyAttach)
char.Torso.ToolGrip.Part0 = char[“Right Arm”]
char.Torso.ToolGrip.Part1 = WeaponTool.BodyAttach
idle:Play()
end)
WeaponTool.Activated:Connect(function()
if char:GetAttribute(“Blocking”) == true then return end
if char:GetAttribute(“BlockBroken”) == true then return end
if char:FindFirstChild(“Stun”) then return end
if char:GetAttribute(“NoM1”) == true then return end
if char:GetAttribute(“Ability”) == true then return end
if not bebe then
bebe = true
if tick() - LTC >= TUCR then -- combo resets after not clicking for a while
combo = 0
end
LTC = tick()
if combo == 0 then
M1:Play()
wait(0.25) -- time before hitbox spawns in
DamageA:FireServer()
combo = combo + 1
wait(0.18) -- to make sure animation ends before starting the next anim/slash
bebe = false
elseif combo == 1 then
M2:Play()
wait(0.25)
DamageA:FireServer()
combo = combo + 1
wait(0.18)
bebe = false
elseif combo == 2 then
M3:Play()
wait(0.25)
DamageA:FireServer()
combo = combo + 1
wait(0.18)
bebe = false
elseif combo == 3 then
M4:Play()
wait(0.25)
DamageC:FireServer()
combo = combo + 1
wait(0.7)
bebe = false
combo = 0
end
end
end)
script.Parent.Unequipped:Connect(function()
game.ReplicatedStorage.DisconnectM6D:FireServer()
idle:Stop()
end)
i havent been able to come up with any kind of solution so i decided to post it here