simple tweening on ONE block(not a mesh) spikes my ping to around 300
My code:
local TweenService = game:GetService("TweenService")
local TI = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local T2 = TweenInfo.new(.2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
local properties = {
Size = Vector3.new(4,5,0.05) -- expanding
}
local properties2 = {
Size = Vector3.new(.1,.1,.1) -- shrinking
}
local Tween = TweenService:Create(i,TI,properties)
Tween:Play()
wait(2)
local Tween2 = TweenService:Create(i,T2,properties2)
Tween2:Play()
Before, my shrinking properties’ value was set to (0,0,0) and i had thought that was what was making it laggy because in my mind, it was trying to round it to the nearest value of 0, which would be like 0.1111111e or something like that, and that would make sense, but after setting it to (.1,.1,.1), i found out that wasnt what was making it lag, so at this point im a bit confused. I even made a debounce to make sure it wasn’t tweening it 1000 times at the same time but no luck.
I also made my tweens faster to compensate, but it’s still there. I even replicated the tween to each client through a remote event, and it still lags as much. Not only does it lag with tweening size, it has the same effect for eg. brickcolor, position, and transparency. I tried these both on my acer nitro 5 laptop which has modern day hardware, AND a new desktop which I had recently just built. It has an RTX something like 2070 so it cannot be a hardware issue.
Your code for the tweening looks fine and should work, Its probably something else like a loop. Check for some more possible reasons your lagging. Anything that runs more than once could be it.
i.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if hit.Parent.Name == Player.Name then
event:FireClient(Player)
if Player.Character.Torso.Transparency ~= 1 and debounce == false then
debounce = true
for i,v in pairs(Player.Character:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Transparency = 1
if v:FindFirstChild("Face") then
v.Face.Transparency = 1
end
if v:FindFirstChild("face") then
v.face.Transparency = 1
end
end
end
When a player touches a part, the touched event often first 20-30 times. Both legs constantly moving up and down, causes the event to fire a lot. You are probably firing the server at least 20 times in a split second and using the server to tween it 20 times. Try adding debounces on the client side.