when ever i shoot my kamehameha it start laggy really bad and it dont lag without the touch interest

repeat
	wait()
until script.Parent:FindFirstChild("Beam2") ~= nil
beam = script.Parent
beam2 = script.Parent.Beam2
end3 = script.Parent.End2
start1 = script.Parent.Start
start2 = script.Parent.Start2
start3 = script.Parent.Start3
start4= script.Parent.Start4
start5 = script.Parent.Start5
end1 = script.Parent.End
end2 = script.Parent.End.Start
hitt = script.Parent.Hit
spin = 0
go = 0
grow = 0 
done = false
repeat
	wait()
until script.Parent.Parent:FindFirstChild("BeamSize") ~= nil
beamsize = script.Parent.Parent:FindFirstChild("BeamSize").Value
Character = script.Parent.Parent
Player = game.Players[Character.Name]
root = script.Parent.Parent:FindFirstChild("HumanoidRootPart")
stop = false
local parts = setmetatable({}, {__mode="k"})
beam.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
    parts[p] = true
damage = Player.Data.Level.Value
				if Character:FindFirstChild("Kaio") ~= nil then
				damage = damage*1.3
			end
			if Character:FindFirstChild("Kaiox3") ~= nil then
				damage = damage*1.5
			end
				if Character:FindFirstChild("SSJ") ~= nil then
				damage = damage*2
			end
			if Character:FindFirstChild("SSJ2") ~= nil then
			damage = damage*3
			end
			if Character:FindFirstChild("SSJ3") ~= nil then
				damage = damage*4
			end
			if Character:FindFirstChild("SSJB") ~= nil then
				damage = damage*8
			end
			if Character:FindFirstChild("SSJR") ~= nil then
				damage = damage*10
			end
			if Character:FindFirstChild("PotaraFused") ~= nil then
				damage = damage*5
		end
				if Character:FindFirstChild("SSJBK") ~= nil then
				damage = damage*12
				end
				if Character:FindFirstChild("SSJBK10s") ~= nil then
				damage = damage*18
				end
				if Character:FindFirstChild("Limit") ~= nil then
			damage = damage*15
			end
				if Character:FindFirstChild("SSJB3") ~= nil then
				damage = damage*25
				end
		if Character:FindFirstChild("Fused") ~= nil then
				damage = damage*3
		end
		if Player.Data.Charging.Value == 1 then
				damage = damage * 2
		end
		humanoid = p.Parent:FindFirstChild("Humanoid")
		torso = p.Parent:FindFirstChild("LowerTorso")
		humanoid.Health = humanoid.Health - damage
		body = Instance.new("BodyVelocity",torso)
		body.Velocity = root.CFrame.lookVector*10
game.Debris:AddItem(body,0.1)
end
end)

beam.TouchEnded:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
    parts[p] = nil
end
end)
coroutine.wrap(function()
   while wait() do
   local parts = hitt:GetTouchingParts()
   for i, part in pairs(parts) do
	if part.Parent then
	if part.Parent:FindFirstChild("Humanoid") == nil then
	if part ~= start1 and part ~= end1 and part~=end2 and part.Name ~= "Base" then
	if part ~= nil then
   stop = true
	else
		stop = false
end
	   end
	
	   
	end
	end
	end
end
end)()
for i = 1,125 do
	wait()
	spin = spin + 1
	if stop == false then
	go = go + (1.5*2)
	grow = grow + (3*2)
	end

	effect = math.random(7+beamsize,10+beamsize)
	effect2 = math.random(11+beamsize,13+beamsize)
	start1.Size = Vector3.new(effect2,effect2,effect2)
	end1.Size = Vector3.new(9.5+beamsize,9.5+beamsize,9.5+beamsize)
	start2.Size = Vector3.new(8.5+beamsize,8.5+beamsize,8.5+beamsize)
	start4.Size = Vector3.new(7.5+beamsize,7.5+beamsize,7.5+beamsize)
	start5.Size = Vector3.new(5.5+beamsize,5.5+beamsize,5.5+beamsize)
	start3.Size = Vector3.new(6.5+beamsize,6.5+beamsize,6.5+beamsize)
	end3.Size = Vector3.new(7.5+beamsize,7.5+beamsize,7.5+beamsize)
	end2.Size = Vector3.new(11+beamsize,10+beamsize,13.5+beamsize)
	beam.Size = Vector3.new(effect,grow,effect)
	beam2.Size = Vector3.new(effect-2,grow,effect-2)
	start1.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start2.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start3.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start4.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (5+beamsize/2)
	start5.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (5+beamsize/2)
	beam.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+go+beamsize/2)
	beam2.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+go+beamsize/2)
	end1.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	end3.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	hitt.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	end2.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+(go*2)+beamsize/2)
end
size1 = start1.Size
size2 = end1.Size
size3 = end2.Size
size4 = beam.Size
for i = 1,5 do
	wait()
	start1.Size = start1.Size + Vector3.new(size1.x/20,0,size1.y/20)
	end1.Size = end1.Size + Vector3.new(size2.x/20,0,size2.y/20)
	end2.Size = end2.Size + Vector3.new(size3.x/20,0,size3.y/20)
	beam.Size = beam.Size + Vector3.new(size4.x/20,0,size4.y/20)
	start1.Transparency =start1.Transparency + 1/5 
	end1.Transparency =end1.Transparency + 1/5
	beam.Transparency =beam.Transparency + 1/5
	end2.Transparency =end2.Transparency + 1/5 
	start1.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start2.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start3.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+beamsize/2)
	start4.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (5+beamsize/2)
	start5.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (5+beamsize/2)
	beam.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+go+beamsize/2)
	beam2.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+go+beamsize/2)
	end1.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	end3.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	hitt.CFrame = root.CFrame*CFrame.Angles(math.rad(270),spin,0)+root.CFrame.lookVector * (6+(go*2)+beamsize/2)
	end2.CFrame = root.CFrame*CFrame.Angles(math.rad(90),spin,0)+root.CFrame.lookVector * (3+(go*2)+beamsize/2)
end

beam:Destroy()

if i remove the touch interest it wont lag but why?

1 comment

0

Tab your code correctly and pinpoint relevant lines for us.