So i have this script in ServerScriptService that handles whether different events/modes are active through a StringValue Instance. It works by listening for a RemoteEvent with a Corresponding name to Fire, and once it does, the script changes the StringValue’s Value into whatever the desired value is supposed to be set.
Now, this code below is what the Script does when a value is set into the StringValue (I.E., If the StringValue is “Spawn” then the script enables some enemies to spawn, etc.)
while true do
wait(3)
if value.Value == "Invasion" then
local spawnstat = math.random(1,3)
if spawnstat == 1 then
wait(2)
local simuliclone1 = simuli1:Clone()
simuliclone1.Parent = SpawnFolder
elseif spawnstat == 2 then
wait(2)
local simuliclone2 = simuli2:Clone()
simuliclone2.Parent = SpawnFolder
elseif spawnstat == 3 then
wait(2)
local simuliclone3 = simuli3:Clone()
simuliclone3.Parent = SpawnFolder
end
elseif value.Value == "Occassion" then
occassionstuff.Parent = OccassionFolder
print("it works")
end
end
The problem is, i don’t know if there is a way to remove the stuff that’s already spawned by the Script once the StringValue has been changed.
For a clearer explanation of what i’m talking about, imagine this:
The StringValue is set to “Spawn”, so the Script spawns in an Egg. now, if the StringValue is now set to “Flood”, then the egg is still there even though the StringValue has been changed to something else.
I’ve tried doing a [if value.Value == not “Spawn” then] but it won’t work for some reason, is there any way i can make it so it does?