Is there a reason this would lag?

Is there a reason this would lag?

local ready = true

while true do
	wait(3)
	if ready == true then
		ready = false
		local zombie = game.ServerStorage.Zombie1
		
		if not game.Workspace.ZombieFolder:FindFirstChild("Zombie2") then
			local newZombie = zombie:Clone()
			newZombie.Name = "Zombie2"
		newZombie.Parent = game.Workspace.ZombieFolder
		newZombie.CFramePart.CFrame = script.Parent.CFrame + Vector3.new(0,10,0)
		
		end
		wait(3)
			ready = true
	end
end
1 Like

The only reason I would think this could lag is if the model has a lot of parts.

2 Likes

There is only one part. :frowning: :frowning: :frowning:

1 Like

I see that you are waiting 6 seconds between each cycle of the loop. Would that be the problem?

the zombie is this model zombie

if the wait() at the top is for debouncing then that is bad

you only need this wait() for a working debounce

I don’t see how the code will lag tho?

either way please tell me why you have a debounce in a while loop, what is the point…

I wrote part of a script and then realized I had another script that worked find so I just changed it.

Updated script:
while true do
```

	wait(1)
	local zombie = game.ServerStorage.Zombie1
	
	if not game.Workspace.ZombieFolder:FindFirstChild("Zombie2") then
		local newZombie = zombie:Clone()
		newZombie.Name = "Zombie2"
	newZombie.Parent = game.Workspace.ZombieFolder
	newZombie.CFramePart.CFrame = script.Parent.CFrame + Vector3.new(0,10,0)
	
end
end
while true do
    wait(6)
    local zombie = game.ServerStorage.Zombie1
    if not workspace.ZombieFolder:FindFirstChild("Zombie2") then
        local newZombie = zombie:Clone()
	    newZombie.Name = "Zombie2"
        newZombie.Parent = workspace.ZombieFolder
        newZombie.CFramePart.CFrame = script.Parent.CFrame + Vector3.new(0,10,0)
    end
end

this shouldn’t even lag at all

After I disable the script it doesn’t lag at all.

After I disable the script it doesn’t lag at all.

how many frames are you losing?

also I edited it just now, I doubt it will fix the lag tho

How do I see how many frames I am losing

don’t you have a frame rate counter?

This code sticks out to me as a reason why it could lag. Does the Zombie1 model contain this script?

No. For both questions. :frowning: :frowning: :frowning:

wasn’t that only one question???

For your question and @JDog005s question.