I wish the game would not lag when the ball touches the player.
As you can see in the corner of the screen, the fps drops from 60 to 51, without the debounce it drops to 1, i put debounce and it improved a lot, but how to take the loss of Fps?
script.Parent.LightBombCriarPoderEvent.OnServerEvent:Connect(function(Player)
--Serviços
local WorkspaceService = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
--Variáveis do player
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")
--Variáveis do script
local Debounce = false
local LightBomb = ReplicatedStorage:WaitForChild("LightBomb")
local Pedras = ReplicatedStorage:WaitForChild("Pedras")
local Explosion = ReplicatedStorage:WaitForChild("Explosion")
--Clones
local LightBombClone = LightBomb:Clone()
LightBombClone.Anchored = true
local ExplosionClone = Explosion:Clone()
--Tweens
local LightBombCloneSubir = TweenService:Create(LightBombClone,TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),{Position = Character.Head.Position + Vector3.new(0,75,0)})
local LightBombCloneExpandir = TweenService:Create(LightBombClone,TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),{Size = Vector3.new(60,60,60)})
local ExplosionCloneSubir = TweenService:Create(ExplosionClone,TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),{Position = Character.Head.Position + Vector3.new(0,75,0)})
local ExplosionCloneExpandir = TweenService:Create(ExplosionClone,TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0),{Size = Vector3.new(60,60,60)})
local BodyVelocity = Instance.new("BodyVelocity", Character.PrimaryPart)
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = Vector3.new(0,100,0)
BodyVelocity.Name = "Subir"
wait(.15)
BodyVelocity:Destroy()
local BodyVelocity2 = Instance.new("BodyVelocity", Character.PrimaryPart)
BodyVelocity2.Velocity = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity2.Velocity = Vector3.new(0,0,0)
BodyVelocity2.Name = "Segurar"
wait(0.95)
LightBombClone.Parent = WorkspaceService
LightBombClone.Position = Character.Head.Position
ExplosionClone.Transparency = 1
ExplosionClone.Parent = WorkspaceService
ExplosionClone.Position = LightBombClone.Position
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = ExplosionClone
Weld.Part1 = LightBombClone
Weld.Parent = ExplosionClone
LightBombCloneSubir:Play()
ExplosionCloneSubir:Play()
LightBombCloneExpandir:Play()
ExplosionCloneExpandir:Play()
wait(5)
LightBombClone.Anchored = false
script.Parent.MousePosition.Disabled = false
local BodyVelocity3 = Instance.new("BodyVelocity")
BodyVelocity3.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity3.Parent = LightBombClone
script.Parent.MouseHitEvent.OnServerEvent:Connect(function(plr, Mouse)
print("Fire Recebido")
BodyVelocity3.Velocity = CFrame.new(LightBombClone.Position, Mouse).LookVector * 45
print("Fire Recebido2")
end)
local Debounce = false
LightBombClone.Touched:Connect(function(Hit)
if not Debounce then
Debounce = true
print("Test")
else
return;
end
end)
wait(1)
script.Parent.MousePosition.Disabled = true
BodyVelocity2:Destroy()
end)