To summarize, I’m creating a fighting game that has different movesets and for one of them when they land, it creates a MASSIVE ping spike at the start. This may have to do with the cloning of models from Server Storage or the amount of instances being created but I’m not so sure. This also ONLY happens in the ACTUAL game and NOT in studio.
Here’s my script: (Sorry for the length of it)
local remote = game:GetService('ReplicatedStorage').Remotes.Attacks.Stw.Punishment
local cs = game:GetService('CollectionService')
local reusedFunctions = require(game:GetService('ReplicatedStorage').Modules.ReusedFunctions)
local tweenService = game:GetService("TweenService")
remote.OnServerEvent:Connect(function(player)
if not cs:HasTag(player.Character, "punishmentCooldown") and not player.Character:FindFirstChild('Stun') and player.Values.Stand.Value == "Stw" then --Preventing stand, cooldown, stun, and range hackers.
cs:AddTag(player.Character, "punishmentCooldown")
cs:AddTag(player, "CantAttack")
task.delay(30, function()--Subtract based on windup
cs:RemoveTag(player.Character, "punishmentCooldown")
end)
local standModel = game:GetService('ServerStorage').Models.Stw.StwHumanoidRig:Clone()
standModel.Parent = workspace.Storage.Objects
game.Debris:AddItem(standModel, 5)
standModel.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
local punishmentAnim = standModel.StandHumanoid:LoadAnimation(standModel.Animations.Punishment)
punishmentAnim:Play()
for _, v in pairs(standModel:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
if v.Name ~= "HumanoidRootPart" then
v.Transparency = 1
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
local highlight = Instance.new('Highlight', standModel)
highlight.FillTransparency = 0
highlight.OutlineTransparency = 1
highlight.FillColor = Color3.new(1, 1, 1)
tweenService:Create(highlight, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FillTransparency = 1}):Play()
game.Debris:AddItem(highlight, .4)
end
end
end
if player.Character["Right Arm"]:FindFirstChild("RightGlove") then
for _, v in pairs(player.Character["Right Arm"].RightGlove:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
tweenService:Create(player.Character["Right Arm"].RightGlove, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
end
end
end
if player.Character["Left Arm"]:FindFirstChild("LeftGlove") then
for _, v in pairs(player.Character["Left Arm"].LeftGlove:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
tweenService:Create(player.Character["Left Arm"].LeftGlove, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
end
end
end
local summonSound = Instance.new("Sound", standModel.HumanoidRootPart)
summonSound.SoundId = "rbxassetid://9088738552"
summonSound.Volume = .5
summonSound.TimePosition = .4
summonSound:Play()
game.Debris:AddItem(summonSound, 2)
local specialSound = Instance.new("Sound", standModel.HumanoidRootPart)
specialSound.SoundId = "rbxassetid://4845894614"
specialSound.Volume = .5
--specialSound.TimePosition = .4
specialSound:Play()
game.Debris:AddItem(specialSound, 2)
tweenService:Create(standModel.HumanoidRootPart, TweenInfo.new(.8, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {CFrame = standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-4)}):Play()
task.wait(.8)
local op = OverlapParams.new()
local hitContents = workspace:GetPartBoundsInBox(standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-3), Vector3.new(5,6,5), op)
local canTouch = true
for _, v in pairs(hitContents) do
local char = v.Parent
if canTouch and char:FindFirstChild('Humanoid') and char ~= player.Character and not char:FindFirstChild('IFrame') and not char:FindFirstChild('Parrying') and not char:FindFirstChild('Tsed') and not char:FindFirstChild('Tsing') then
canTouch = false
local hit = v
local stun = Instance.new("BoolValue", hit.Parent)
stun.Name = "Stun"
game.Debris:AddItem(stun, .8)
local iframeU = Instance.new('BoolValue', player.Character)
iframeU.Name = "IFrame"
game.Debris:AddItem(iframeU, .8)
local iframe = Instance.new('BoolValue', hit.Parent)
iframe.Name = "IFrame"
game.Debris:AddItem(iframe, .8)
hit.Parent.HumanoidRootPart.Anchored = true
local cancelBlock = Instance.new('BoolValue', hit.Parent)
cancelBlock.Name = "CancelBlock"
game.Debris:AddItem(cancelBlock, .1)
local hitSound = Instance.new("Sound", standModel.HumanoidRootPart)
hitSound.SoundId = "rbxassetid://9076225494"
hitSound.Volume = .25
hitSound:Play()
game.Debris:AddItem(hitSound, .8)
local victimAnim = hit.Parent.Humanoid:LoadAnimation(script.Victim)
victimAnim:Play()
local hitVFX1 = game:GetService('ReplicatedStorage').VFX.HitVFX2:Clone()
hitVFX1.Parent = workspace.Storage.Effects
hitVFX1.CFrame = hit.Parent.Torso.CFrame
local hitVFX1Weld = Instance.new('WeldConstraint', hitVFX1)
hitVFX1Weld.Part0 = hit.Parent.Torso
hitVFX1Weld.Part1 = hitVFX1
for _, v in pairs(hitVFX1:GetDescendants()) do
if v:IsA('ParticleEmitter') then
v:Emit(15)
end
end
game.Debris:AddItem(hitVFX1, 2)
local kniveRig = game:GetService('ServerStorage').Models.Stw.KnivesRig:Clone()
kniveRig.Parent = workspace.Storage.Objects
kniveRig.HumanoidRootPart.CFrame = hit.Parent.HumanoidRootPart.CFrame
local kniveAnim = kniveRig.ObjectHumanoid:LoadAnimation(kniveRig.Animations.Punishment):Play()
game.Debris:AddItem(kniveRig, .8)
local tsingValue = Instance.new("NumberValue", player.Character)
tsingValue.Name = "Tsing"
tsingValue.Value = .8
game.Debris:AddItem(tsingValue, .8)
local tsedValue = Instance.new("NumberValue", v.Parent)
tsedValue.Name = "Tsed"
tsedValue.Value = .8
game.Debris:AddItem(tsedValue, .8)
local tsSound = Instance.new("Sound", standModel.HumanoidRootPart)
tsSound.SoundId = "rbxassetid://2502245370"
tsSound.Volume = 1
tsSound.TimePosition = .3
tsSound:Play()
game.Debris:AddItem(tsSound, 4)
task.wait(.8)
reusedFunctions.damage(20, hit.Parent, player.Character)
hit.Parent.HumanoidRootPart.Anchored = false
victimAnim:Stop()
local laughSound = Instance.new("Sound", player.Character.HumanoidRootPart)
laughSound.SoundId = "rbxassetid://5482711860"
laughSound.Volume = .5
laughSound:Play()
game.Debris:AddItem(laughSound, 1)
local stabSound = Instance.new("Sound", hit.Parent.HumanoidRootPart)
stabSound.SoundId = "rbxassetid://5951833277"
stabSound.Volume = .5
stabSound:Play()
game.Debris:AddItem(stabSound, 2)
local hitVFX2 = game:GetService('ReplicatedStorage').VFX.HitVFX2:Clone()
hitVFX2.Parent = workspace.Storage.Effects
hitVFX2.CFrame = hit.Parent.Torso.CFrame
local hitVFX2Weld = Instance.new('WeldConstraint', hitVFX2)
hitVFX2Weld.Part0 = hit.Parent.Torso
hitVFX2Weld.Part1 = hitVFX2
for _, v in pairs(hitVFX2:GetDescendants()) do
if v:IsA('ParticleEmitter') then
v:Emit(25)
end
end
game.Debris:AddItem(hitVFX2, 2)
local bloodVFX = game:GetService('ReplicatedStorage').VFX.BloodVFX1:Clone()
bloodVFX.Parent = workspace.Storage.Effects
bloodVFX.CFrame = hit.Parent.Torso.CFrame
local bloodVFXWeld = Instance.new('WeldConstraint', bloodVFX)
bloodVFXWeld.Part0 = hit.Parent.Torso
bloodVFXWeld.Part1 = bloodVFX
for _, v in pairs(bloodVFX:GetDescendants()) do
if v:IsA('ParticleEmitter') then
v:Emit(60)
end
end
game.Debris:AddItem(bloodVFX, 2)
elseif canTouch and char:FindFirstChild('Parrying') and not char:FindFirstChild('IFrame') and char:FindFirstChild('Humanoid') and char ~= player.Character then
canTouch = false
reusedFunctions.runParry(player.Character, char)
end
end
task.wait(.4)
cs:RemoveTag(player, "CantAttack")
for _, v in pairs(standModel:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
if v.Name ~= "HumanoidRootPart" then
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
local highlight = Instance.new('Highlight', standModel)
highlight.FillTransparency = 0
highlight.OutlineTransparency = 1
highlight.FillColor = Color3.new(1, 1, 1)
tweenService:Create(highlight, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FillTransparency = 1}):Play()
game.Debris:AddItem(highlight, .2)
end
end
end
if player.Character["Right Arm"]:FindFirstChild("RightGlove") then
for _, v in pairs(player.Character["Right Arm"].RightGlove:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
tweenService:Create(player.Character["Right Arm"].RightGlove, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
end
end
end
if player.Character["Left Arm"]:FindFirstChild("LeftGlove") then
for _, v in pairs(player.Character["Left Arm"].LeftGlove:GetDescendants()) do
if v:IsA('BasePart') or v:IsA("BaseMesh") then
tweenService:Create(player.Character["Left Arm"].LeftGlove, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
end
end
end
local unsummonSound = Instance.new("Sound", standModel.HumanoidRootPart)
unsummonSound.SoundId = "rbxassetid://6938611595"
unsummonSound.Volume = .5
unsummonSound:Play()
end--//Exploit Check End
end)
If I could get this issue solved with the help of anyone I would greatly appreciate it!