Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make this shield expand regardless of server lag?

Asked by 8 years ago

When the server lags, like if there are more than 50 NPCs, the circle expands slower than if there were no NPCs at all. Is there a way to make the circle expand like a real explosion, with the server lag?

This is my script, it probably isn't as efficient.

        for i = 1,50 do
            wait(0.0001)
            ex.Size = ex.Size + Vector3.new(1,1,1)
            ex.CFrame =  CFrame.new(torso.CFrame.p)
                ex.Touched:connect(function(part)
                    if part.Parent:FindFirstChild("Humanoid") then
                        part.Parent:FindFirstChild("Humanoid").Health = part.Parent:FindFirstChild("Humanoid").Health - 5
                end
            end)
        end
0
A more efficient option would be to use custom particles, then do some math or raycasting (or both) to damage the players. That way you don't have a moving object. Perci1 4988 — 8y
0
Your wait() won't go below .03, regardless of what you put in the value. Run your graphics on your client (NPC bodies, particle effects and such) while you run your game logic (NPC positions, action positions) on the server. This should help with the lag. You can't just ignore lag. Legojoker 345 — 8y

Answer this question