You can write your topic however you want, but you need to answer these questions:
-
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. -
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.
-
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
spawningbase:GetPropertyChangedSignal("Value"):Connect(function()
while true do
wait(spawnrate)
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")
end
end
end)