Number value doesn't change

Hi! I was making a Blur system with a value for the amount of blurs which popped up. I stumbled upon the error was:

“Insanity” was not found

My code:

local randomwait = math.random(300,800)
local Insanity = game.Players.LocalPlayer.PlayerScripts:WaitForChild("Insanity")


while true do
	wait (randomwait)
	if Insanity ~= 0 then
		local size = 20
		local blur  = Instance.new("BlurEffect")
		
		blur.Enabled = true
		blur.Size = size
		blur.Parent = workspace.CurrentCamera
		
		game.Players.LocalPlayer.PlayerGui.Stage1.Enabled = true
		
		wait(10)
		
		blur:Destroy()
		Insanity.Value = Insanity.Value +1
	end
end

Can we see your studio hierarchy?

image

local insanity = game:GetService("Players").LocalPlayer.StarterPlayer.StarterPlayerScripts:WaitForChild("Insanity")

It didn’t work.

30charactersss

Did u get any error? (30 characters)

“Insanity” was not found

30char

That is actually strange, I just tested it out:
image
image

Make sure you are using a LocalScript, as Scripts cannot access Player.PlayerScripts.

I am using a LocalScript.

30char

Try writing Insanity.Value ~=0 instead.

The blur works, but the number value doesn;t.

Did you replace the line of code I provided?

I did, the blur works but the Insanity.Value = Insanity.Value +1 doesn’t work.

perhaps these are causing delays? 300 - 800 seconds seems awfully long to me

I used a wait(1) to test it. The blur works fine and as expected, but the NumberValue doesn’t change at all.

Are you sure “Insanity” is a NumberValue? If so, maybe the wait(10) is causing a delay?

I waited the 10 seconds, the blur stopped for a second and then looped instead of the NumberValue being changed.

Try adding print(Insanity.Value) at the end of your loop, and see what it prints out.

The output showed 1. But the blur stopped working at all.

local randomwait = math.random(300,800)
local Insanity = game.Players.LocalPlayer.PlayerScripts:WaitForChild("Insanity")


while true do
	wait (1)
	if Insanity.Value ~= 0 then
		local size = 20
		local blur  = Instance.new("BlurEffect")
		
		blur.Enabled = true
		blur.Size = size
		blur.Parent = workspace.CurrentCamera
		
		game.Players.LocalPlayer.PlayerGui.Stage1.Enabled = true
		
		wait(10)
		
		blur:Destroy()
		Insanity.Value = Insanity.Value +1
		print(Insanity.Value)
	end
end