I can't get my clown spawner to stop

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make my script spawn clowns at the rate of the bool “SpawningRate” when the bool “Spawning” is true. I need it to stop when “Spawning” is false.

  2. What is the issue? Include screenshots / videos if possible!
    When the bool is set to true, it spawns clowns just fine. Whenever I set the bool to false though, the clowns don’t stop spawning. The clowns are intended to stop spawning when it is set to false.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked around the developer forums for awhile. I tried using .Changed for the bool, but it didn’t work either. I’m stumped on how to fix this.

Here is my code, if anyone could give me any pointers as to how to fix this, it would be much appreciated! This is my first post on the DevFourm, so sorry if I accidentally messed something up.

local spawner = script.Parent -- The spawn location
local Clown = game:GetService("ReplicatedStorage").Clown
local spawningbase = game:GetService("ReplicatedStorage").Spawning -- BoolValue
local spawnrate = game:GetService("ReplicatedStorage").SpawnRate.Value -- NumberValue

	while true do
		if spawningbase.Value == true then -- When the value is true.
			local clownClone = Clown:Clone()
			clownClone.Parent = script.Parent
		else -- When the value is false.
			print("Not Spawning")

Do you change the value on the client or server?

I changed the value on the server.

Can I see where you change the value?

Right now I’m just going into playtest mode then going to the server view and switching the value manually. I plan to have a script turn it on and off and change the spawnrate to make a wave-based game.

see what happens if you change it with a script.

That worked, it was such a simple solution, I should’ve thought of it. Thanks for helping.

1 Like

Your welcome! Glad I could help!