I’m creating an Attack on Titan game in which there are large NPC’s that attack and try to eat you (titans) However, when more than one titans gang up on you, the FPS drops significantly and the game literally begins deteriorating. This is the attack script inside of every titan:
I seriously don’t know what the issue is, somebody please help.
local titan = script.Parent
local humanoid = titan:FindFirstChild("Humanoid")
local root = titan:FindFirstChild("HumanoidRootPart")
local hitboxes = titan:FindFirstChild("Hitboxes")
local walkspeed = humanoid.WalkSpeed
local rightgrabbing = false
local leftgrabbing = false
local stomping = false
local blind = false
local biting = false
local anims = titan:FindFirstChild("Animations")
local debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local grabcd = false
local stompcd = false
local eating = false
local bitecd = false
local victim
local lefttendonslashed = titan:FindFirstChild("LeftTendonSlashed").Value
local righttendonslashed = titan:FindFirstChild("RightTendonSlashed").Value
local tendonsslashed = titan:FindFirstChild("TendonsSlashed")
hitboxes:FindFirstChild("Nape").Touched:Connect(function(hit)
if hit.Name == "LBlade" or hit.Name == "RBlade" then
if hit.Transparency == 0 then
if hit:FindFirstChild("Trail") then
if hit.Trail.Enabled == true then
humanoid:TakeDamage(math.huge)
local playerr = game.Players:GetPlayerFromCharacter(hit.Parent.Parent.Parent)
local color = script:FindFirstChild("ColorScript"):Clone()
color.Parent = playerr.PlayerGui
color.Enabled = true
--playerr.Data.Exp.Value += 100
-- playerr.PlayerGui:FindFirstChild("MarleyKill").Frame.Count.Visible = true
-- playerr.PlayerGui:FindFirstChild("MarleyKill").Frame.Blood.Visible = true
--playerr.PlayerGui:FindFirstChild("MarleyKill").Frame.Damage4:Play()
--wait(2)
-- playerr.PlayerGui:FindFirstChild("MarleyKill").Frame.Count.Visible = false
-- playerr.PlayerGui:FindFirstChild("MarleyKill").Frame.Blood.Visible = false
end
end
end
end
end)
hitboxes:FindFirstChild("Eye Box").Touched:Connect(function(hit)
if hit.Name == "LBlade" or hit.Name == "ExplosionParticle" and blind == false then
if hit.Transparency == 0 then
if hit:FindFirstChild("Trail") then
if hit.Trail.Enabled == true then
blind = true
humanoid.WalkSpeed = 0
root.BodyGyro.P = 0
hitboxes['Eye Box'].Slashed:Play()
for i, v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
local blindIdle = humanoid:LoadAnimation(anims.Blind)
blindIdle:Play()
hitboxes["Eye Box"]:FindFirstChild("Blood").Enabled = true
hitboxes["Eye Box"]:FindFirstChild("Blood2").Enabled = true
hitboxes["Eye Box"]:FindFirstChild("BloodHit").Enabled = true
hitboxes["Eye Box"]:FindFirstChild("slash5").Enabled = true
hitboxes["Eye Box"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
wait(10)
blind = false
humanoid.WalkSpeed = walkspeed
root.BodyGyro.P = 500
blindIdle:Stop()
hitboxes["Eye Box"]:FindFirstChild("Blood").Enabled = false
hitboxes["Eye Box"]:FindFirstChild("Blood2").Enabled = false
hitboxes["Eye Box"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["Eye Box"]:FindFirstChild("slash5").Enabled = false
hitboxes["Eye Box"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
end
end
end
end
end)
tendonsslashed.Changed:Connect(function()
if tendonsslashed.Value == true then
humanoid.WalkSpeed = 0
root.BodyGyro.P = 0
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Stunned"))
anim:Play()
wait(10)
anim:Stop()
humanoid.WalkSpeed = walkspeed
root.BodyGyro.P = 500
tendonsslashed.Value = false
end
end)
hitboxes:FindFirstChild("LeftTendon").Touched:Connect(function(hit)
if hit.Name == "LBlade" and lefttendonslashed == false then
if hit.Trail.Enabled == true then
lefttendonslashed = true
hitboxes["LeftTendon"]:FindFirstChild("Slashed"):Play()
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
if righttendonslashed == true then
tendonsslashed.Value = true
end
wait(4)
if tendonsslashed.Value == false then
lefttendonslashed = false
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
elseif tendonsslashed.Value == true then
wait(10)
lefttendonslashed = false
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
end
end
elseif hit. name == "exp" or hit.Name == "Bullet" then
lefttendonslashed = true
hitboxes["LeftTendon"]:FindFirstChild("Slashed"):Play()
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = true
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
if righttendonslashed == true then
tendonsslashed.Value = true
end
wait(4)
if tendonsslashed.Value == false then
lefttendonslashed = false
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
elseif tendonsslashed.Value == true then
wait(10)
lefttendonslashed = false
hitboxes["LeftTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["LeftTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
end
end
end)
hitboxes:FindFirstChild("RightTendon").Touched:Connect(function(hit)
if hit.Name == "LBlade" and righttendonslashed == false then
if hit.Trail.Enabled == true then
righttendonslashed = true
hitboxes["RightTendon"]:FindFirstChild("Slashed"):Play()
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
if lefttendonslashed == true then
tendonsslashed.Value = true
end
wait(3)
if tendonsslashed.Value == false then
righttendonslashed = false
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
elseif tendonsslashed.Value == true then
wait(10)
righttendonslashed = false
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
end
end
elseif hit.Name == "exp" or hit.Name == "Bullet" then
righttendonslashed = true
hitboxes["RightTendon"]:FindFirstChild("Slashed"):Play()
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = true
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
if lefttendonslashed == true then
tendonsslashed.Value = true
end
wait(3)
if tendonsslashed.Value == false then
righttendonslashed = false
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
elseif tendonsslashed.Value == true then
wait(10)
righttendonslashed = false
hitboxes["RightTendon"]:FindFirstChild("Blood").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Blood2").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("BloodHit").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("slash5").Enabled = false
hitboxes["RightTendon"]:FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = false
end
end
end)
hitboxes:FindFirstChild("LeftGrabZone").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not grabcd and not eating and hit.Parent:FindFirstChild("Torso") then
grabcd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("LeftSwing"))
anim:Play()
wait(2)
grabcd = false
end
end)
hitboxes:FindFirstChild("BiteZone").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not bitecd and not eating and hit.Parent:FindFirstChild("Torso") then
bitecd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Bite"))
anim:Play()
wait(3)
bitecd = false
end
end)
hitboxes:FindFirstChild("Mouth Box").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if bitecd and not eating and hit.Parent:FindFirstChild("Torso") then
root.Anchored = true
p.Character:PivotTo(hitboxes:FindFirstChild("Mouth Box").CFrame)
p.Character:FindFirstChild("Humanoid").PlatformStand = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Eating"))
anim:Play()
eating = true
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("WeldConstraint").Part1 = p.Character:FindFirstChild("Torso")
wait(.5)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1"):Emit(10)
wait(1)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1"):Emit(10)
wait(1)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1"):Emit(10)
wait(1)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("WeldConstraint").Part1 = nil
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1"):Emit(10)
root.Anchored = false
wait(1)
eating = false
end
end)
hitboxes:FindFirstChild("RightGrabZone").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not grabcd and not eating and hit.Parent:FindFirstChild("Torso") then
grabcd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("RightSwing"))
anim:Play()
wait(2)
grabcd = false
end
end)
hitboxes:FindFirstChild("StompZone").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not stompcd and not eating and hit.Parent:FindFirstChild("Torso") then
stompcd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Stomp"))
anim.Priority = Enum.AnimationPriority.Action4
anim:Play()
wait(.5)
titan:FindFirstChild("Stomping").Value = true
root:FindFirstChild('T-Rex Stomp'):Play()
wait(1.5)
titan:FindFirstChild("Stomping").Value = false
stompcd = false
end
end)
local dmgcd = false
hitboxes:FindFirstChild("Right Foot Box").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if stompcd and hit.Parent:FindFirstChild("Torso") and dmgcd == false then
dmgcd = true
wait(1)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(40)
hit.Parent:FindFirstChild("Humanoid").PlatformStand = true
local velocity = Instance.new("BodyVelocity")
velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
velocity.Velocity = root.CFrame.LookVector * 100
velocity.Parent = hit.Parent:FindFirstChild("Torso")
game:GetService("Debris"):AddItem(velocity,0.1)
wait(2)
hit.Parent:FindFirstChild("Humanoid").PlatformStand = false
dmgcd = false
end
end)
hitboxes:FindFirstChild("NapeGrabZone").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not grabcd and not eating and hit.Parent:FindFirstChild("Torso") then
grabcd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("NapeSwatRight"))
anim:Play()
wait(2)
grabcd = false
end
end)
hitboxes:FindFirstChild("Right Hand Box").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not eating and grabcd and hit.Parent:FindFirstChild("Torso") then
if p.Character:FindFirstChild("Humanoid").Health > 0 then
root.Anchored = true
local victim = p
p.Character:PivotTo(hitboxes:FindFirstChild("RightHold").CFrame)
hitboxes:FindFirstChild("RightHold"):FindFirstChild("WeldConstraint").Part1 = victim.Character:FindFirstChild("HumanoidRootPart")
eating = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("RightGrab"))
anim:Play()
wait(1.5)
if humanoid.Health > 0 then
hitboxes:FindFirstChild("RightHold"):FindFirstChild("WeldConstraint").Part1 = nil
victim.Character:FindFirstChild("Humanoid"):TakeDamage(math.huge)
victim.Character:FindFirstChild("Torso"):FindFirstChild("Left Hip"):Destroy()
victim.Character:FindFirstChild("Torso"):FindFirstChild("Right Hip"):Destroy()
hitboxes:FindFirstChild("Right Hand Box"):FindFirstChild("body_medium_impact_hard4_blood"):Play()
hitboxes:FindFirstChild("Right Hand Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1").Enabled = true
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit2").Enabled = true
wait(0.2)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1").Enabled = false
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit2").Enabled = false
wait(0.8)
root.Anchored = false
eating = false
end
end
end
end)
hitboxes:FindFirstChild("Left Hand Box").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not eating and grabcd and hit.Parent:FindFirstChild("Torso") then
if p.Character:FindFirstChild("Humanoid").Health > 0 then
root.Anchored = true
local victim = p
p.Character:PivotTo(hitboxes:FindFirstChild("LeftHold").CFrame)
hitboxes:FindFirstChild("LeftHold"):FindFirstChild("WeldConstraint").Part1 = victim.Character:FindFirstChild("HumanoidRootPart")
eating = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("LeftGrab"))
anim:Play()
wait(1)
if humanoid.Health > 0 then
hitboxes:FindFirstChild("LeftHold"):FindFirstChild("WeldConstraint").Part1 = nil
victim.Character:FindFirstChild("Humanoid"):TakeDamage(math.huge)
victim.Character:FindFirstChild("Torso"):FindFirstChild("Neck"):Destroy()
hitboxes:FindFirstChild("Right Hand Box"):FindFirstChild("body_medium_impact_hard4_blood"):Play()
hitboxes:FindFirstChild("Right Hand Box"):FindFirstChild("Big Blood Damage 1"):Play()
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1").Enabled = true
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit2").Enabled = true
wait(0.2)
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit1").Enabled = false
hitboxes:FindFirstChild("Mouth Box"):FindFirstChild("BloodHit2").Enabled = false
wait(0.8)
root.Anchored = false
eating = false
end
end
end
end)
local titanbitecd = false
hitboxes:FindFirstChild("Main").Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p and not blind and not eating and titanbitecd == false and hit.Parent:FindFirstChild("UpperTorso") and hit.Parent:FindFirstChild("BodyHardening").Value == false then
titanbitecd = true
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Bite")):Play()
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2000)
wait(2)
titanbitecd = false
elseif hit.Parent:FindFirstChild("BodyHardening").Value == true then
local anim = humanoid:FindFirstChild("Animator"):LoadAnimation(anims:FindFirstChild("Bite")):Play()
titan:FindFirstChild("Head").Name = "nothead"
titan:FindFirstChild("BodyHardening").Value = true
titan:FindFirstChild("BodyHardened").Value = true
hitboxes:Destroy()
titan:FindFirstChild("Handle"):Destroy()
titan:FindFirstChild("Humanoid"):Destroy()
titan:FindFirstChild("Chase"):Destroy()
for i,v in pairs(titan:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = true
local tween = game:GetService("TweenService"):Create(v,TweenInfo.new(10),{Color = Color3.new(0.356863, 0.364706, 0.411765)}):Play()
v.Material = Enum.Material.Ice
v.CanCollide = true
elseif v:IsA("ParticleEmitter") or v:IsA("SurfaceAppearance") or v:IsA("Decal") or v:IsA("Texture") or v:IsA("Beam") then
v:Destroy()
elseif v:IsA("Sound") and v.Name ~= "BodyHarden" then
v:Destroy()
end
end
end
end)
humanoid.Died:connect(function()
titan:FindFirstChild("UpperTorso"):FindFirstChild("BloodBeam"):FindFirstChild("Blood").Enabled = true
titan:FindFirstChild("UpperTorso"):FindFirstChild("BloodBeam"):FindFirstChild("Blood2").Enabled = true
titan:FindFirstChild("UpperTorso"):FindFirstChild("BloodBeam"):FindFirstChild("BloodHit").Enabled = true
titan:FindFirstChild("UpperTorso"):FindFirstChild("BloodBeam"):FindFirstChild("slash5").Enabled = true
titan:FindFirstChild("UpperTorso"):FindFirstChild("BloodBeam"):FindFirstChild("Attachment"):FindFirstChild("ParticleEmitter").Enabled = true
hitboxes:Destroy()
debris:AddItem(titan, 10)
for k,v in pairs(titan:GetChildren()) do
if v:IsA("Accoutrement") then
v:Destroy()
end
end
wait(3)
for k,v in pairs(titan:GetDescendants()) do
if v:isA("BasePart") then
TweenService:Create(v, TweenInfo.new(10), {Transparency = 1}):Play()
end
end
end)
humanoid.Changed:Connect(function()
if humanoid.Sit == true then
humanoid.Jump = true
end
end)