When I shoot, my FPS drops, how can I optimize this script?
Local Script:
game.ReplicatedStorage["Выстрел из оружия(верт)"].OnClientEvent:Connect(function(MG1, MG2)
local bullet = game.ReplicatedStorage.Bullet:Clone()
bullet.LinearVelocity.VectorVelocity = MG1.CFrame.LookVector * 1000
bullet.Parent = workspace
bullet.CFrame = MG1.CFrame
game:GetService("Debris"):AddItem(bullet, 5)
bullet.Touched:Connect(function(hit)
if hit.Name == "Bullet" or hit.Name == "Body" then return end
local humanoid = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
game.ReplicatedStorage["Нанесение урона на литл"]:FireServer(humanoid)
end
bullet:Destroy()
end)
local bullet2 = game.ReplicatedStorage.Bullet:Clone()
bullet2.LinearVelocity.VectorVelocity = MG2.CFrame.LookVector * 1000
bullet2.Parent = workspace
bullet2.CFrame = MG2.CFrame
game:GetService("Debris"):AddItem(bullet, 5)
bullet2.Touched:Connect(function(hit)
if hit.Name == "Bullet" or hit.Name == "Body" then return end
local humanoid = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
game.ReplicatedStorage["Нанесение урона на литл"]:FireServer(humanoid)
end
bullet2:Destroy()
end)
end)