I am creating the behavior of SCP-096, but I have a question about how to make this order of actions, which is the cycle of the SCP sitting, could be broken and not executed when the SCP enters the stage of aggression. I use the Brutez model, so you experiment on it when solving the issue. And this script is a Brutez Script.
Here’s a model: https://create.roblox.com/marketplace/asset/520417089/SCP096.
And here’s a part of the script:
if SCP096Script and SCP096 and Idle and not Idle.IsPlaying then
Sit:Play()
wait(math.random(6, 12))
Sit:Stop()
Sit2Start:Play()
wait(Sit2Start.Length/0.92)
Sit2:Play()
wait(math.random(6, 12))
Sit2:Stop()
Sit2Start:Play()
wait(Sit2End.Length/0.92)
Sit:Play()
Idle:Play();
end;
local sitCycle -- define outside of if statement to interrupt the cycle later
if SCP096Script and SCP096 and Idle and not Idle.IsPlaying then
sitCycle = coroutine.create(function() -- creates our coroutine
Sit:Play()
wait(math.random(6, 12))
Sit:Stop()
Sit2Start:Play()
wait(Sit2Start.Length/0.92)
Sit2:Play()
wait(math.random(6, 12))
Sit2:Stop()
Sit2Start:Play()
wait(Sit2End.Length/0.92)
Sit:Play()
Idle:Play();
end)
coroutine.resume(sitCycle) -- starts the cycle
end;
--when you need to interrupt it
coroutine.close(sitCycle) -- stop it
sitCycle = nil -- delete reference to it