Screen Shake isn't stopping

Hello! My screen shake works when I want it to, but then when I stop it by disabling or deleteing it in a script, it keeps going and isn’t stopping I’m not sure how to make it stop.

ScreenShake Script: function shake()
local players = game.Players:GetPlayers()
for i=1, #players do
local character = players[i].Character
local shakescript = character:FindFirstChild(“ShakeScript”)
if shakescript ~= nil then
shakescript.Disabled = false
end
end
end

script.ShakeScriptAdder.ShakeScript.Disabled=false
shake()

ShakeScriptAdder: local players = game.Players:GetPlayers()

for i=1, #players do
local player = players[i]
if player.Character ~= nil then
script.ShakeScript:clone().Parent = player.Character
end
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
script.ShakeScript:clone().Parent = character
end)
end)

ShakeScript: while true do
local cam = workspace.CurrentCamera
cam.CFrame=cam.CFrame*CFrame.Angles(math.random(-3,3)/360,math.random(-3,3)/360,math.random(-3,3)/360)
cam.FieldOfView=math.random(69,71)
wait()
end

Remember the actual script doing the shake is now in their Players.NAME.PlayerGui.ShakeScript
Not in game.StarterGui … where you are editing the script.

You never actually stop shaking it. It just enables the script and doesn’t disable it.

I’m editing the script in startergui

It does disable it when i use the startergui script.

Replace the while true do loop with a for loop.

How would I do a for loop? I don’t know what that means.

Just replace while true do with for i = 1, 10 do and replace the 10 with how many times you want it to loop.