Is roblox just having issues with :WaitForChild again?

Hi. I’m working on a game called Castle Period and, CONGRATS MY BLUR WONT REMOVE
It keeps saying infinte yield possible on Lighting:WaitForChild(“UIBlur”). I’ve tried everything, everything, literally EVERYTHING and it wants to keep saying that. The code:

local Player = script.Parent.Parent.Parent
local Content = script.Parent.CharacterFrame.ScrollingFrame.Content
local Characters = game.ReplicatedStorage.Characters
local SetSubject = Characters.Parent.SetSubject

local Create = Instance.new

for index,item in pairs(Characters:GetChildren()) do
	if item:FindFirstChild("Humanoid") then
		local ViewportFrame = Instance.new("ViewportFrame")
		ViewportFrame.Parent = Content
		ViewportFrame.BackgroundTransparency = 0.85
		ViewportFrame.BackgroundColor3 = Color3.new(0,0,0)
		
		local Corner = Create("UICorner",ViewportFrame)

		local Button = Create("TextButton")
		Button.Parent = ViewportFrame
		Button.Position = UDim2.new(0,0,1,0)
		Button.Size = UDim2.new(1,0,0,15)
		Button.BorderSizePixel = 0
		Button.BackgroundColor3 = Color3.fromRGB(137, 255, 141)
		Button.Text = "Spawn"
		Button.TextScaled = true
		Button.FontFace = Font.new("Titillium Web", Enum.FontWeight.Thin, Enum.FontStyle.Italic)

		local Preview = item:Clone()
		Preview.Parent = ViewportFrame

		local Camera = Create("Camera")
		print(Camera.Parent)
		Camera.Parent = ViewportFrame
		Camera.CFrame = Preview.Head.CFrame + Preview.Head.CFrame.LookVector * 5
		Camera.CFrame = CFrame.new(Camera.CFrame.Position,Preview.Head.Position)

		ViewportFrame.CurrentCamera = Camera

		Button.MouseButton1Down:Connect(function()
			script.Parent.Enabled = false
			local ChosenCharacter = item:Clone()
			local CurrentCharacter = Player.Character
			local LocalScripts = {}

			for index2,item2 in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
				if item2:IsA('LocalScript') then
					table.insert(LocalScripts,item2:Clone())
				else
					item2:Clone().Parent = ChosenCharacter
				end
			end

			CurrentCharacter.Health:Clone().Parent = ChosenCharacter
			table.insert(LocalScripts,CurrentCharacter.Animate:Clone())     
			ChosenCharacter.Parent = workspace
			Player.Character = ChosenCharacter
			for index2,item2 in pairs(LocalScripts) do
				item2.Parent = ChosenCharacter
			end 
			SetSubject:FireClient(Player,ChosenCharacter.Humanoid)

			local Connection

			local function onDied()
				wait(game.Players.RespawnTime)
				Player:LoadCharacter()
				script.Parent.Enabled = true
				if Connection then
					Connection:Disconnect()
				end
			end

			Connection = ChosenCharacter.Humanoid.Died:Connect(onDied)
			a = game.Lighting:WaitForChild("UIBlur", 5)
			if a:IsA("BlurEffect") then
				a.Size = 0
			end
		end)

	end
end

I’ve searched it up and renamed it. It exists! I swear-

1 Like

Where do you create the BlurEffect object?

I have two possible solutions:

  1. Instead of checking if a:IsA("BlurEffect"), check if a ~= nil.
  2. Instead of checking if a:IsA("BlurEffect"), check if a:IsA("PostEffect"). PostEffect is the superclass of BlurEffect, so it might work. Let me know.

Now it says 03:55:23.004 Players.JustAGameDeveloper1.PlayerGui.BindUI.CharacterScript:78: attempt to index nil with ‘Size’ - Studio

Which one did you try? Depending on the solution you used, the solution I need to give might be different.

1:

a = game.Lighting:WaitForChild("UIBlur")
			if a ~= nil then
				warn("OH NOES!")
			else
				print("woohoo!")
				a.Size = 0
			end

okay well first off, that check should be a == nil not a ~= nil because the ~= means not equal to.
second off, that means your a variable is nil. try this:

a = game.Lighting:WaitForChild("UIBlur")
if a == nil then
	a = game.Lighting:WaitForChild("UIBlur")
end
a.Size = 0

and let me know how that works. You could also set a.Enabled = false instead of a.Size = 0, but right now a = nil so you gotta fix that.

04:01:52.407 Infinite yield possible on 'Lighting:WaitForChild("UIBlur")' - Studio
Nope, no luck.

Try game:GetService("Lighting"):WaitForChild("UIBlur") instead. Think I read somewhere in documentation you need to GetService Lighting.

It’s the same error again.

Where do you create the BlurEffect?

StarterGui.BindUI.Bind

Source:


local UIS = game.UserInputService
local Create = Instance.new

local Lighting = game.Lighting
BlurEffect = Create("BlurEffect", Lighting)
BlurEffect.Size = 0

local StarterGui = game:GetService("StarterGui")

Connect = UIS.InputBegan:Connect(function(inputObject, event)
	if event then 
		return
	end
	if inputObject.KeyCode == Enum.KeyCode.C then
		script.Pressed_Key_C.Value = not script.Pressed_Key_C.Value

		module = require(script.ModuleScript)
		if script.Pressed_Key_C.Value == true then
			module.new(
				script.Parent.StatFrame,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Position = UDim2.new(0.5,0,0.5,0)}
			)
			module.new(
				BlurEffect,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Size = 50}
			)
			StarterGui:SetCore("TopbarEnabled", false)

		else
			module.new(
				script.Parent.StatFrame,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Position = UDim2.new(0.5,0,-1,0)}
			)

			
			module.new(
				BlurEffect,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Size = 0}
			)
			StarterGui:SetCore("TopbarEnabled", true)
			
		end
	end
end)



local UIS = game.UserInputService
local Create = Instance.new

local Lighting = game.Lighting
BlurEffect = Create("BlurEffect", Lighting)
BlurEffect.Size = 0
BlurEffect.Name = "UIBlur"

local StarterGui = game:GetService("StarterGui")

Connect = UIS.InputBegan:Connect(function(inputObject, event)
	if event then 
		return
	end
	if inputObject.KeyCode == Enum.KeyCode.X then
		script.Pressed_Key_X.Value = not script.Pressed_Key_X.Value

		module = require(script.ModuleScript)
		if script.Pressed_Key_X.Value == true then
			module.new(
				script.Parent.CharacterFrame,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Position = UDim2.new(0.5,0,0.5,0)}
			)
			module.new(
				BlurEffect,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Size = 50}
			)
			
	
			StarterGui:SetCore("TopbarEnabled", false)

		else
			module.new(
				script.Parent.CharacterFrame,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Position = UDim2.new(0.5,0,-1,0)}
			)


			module.new(
				BlurEffect,
				TweenInfo.new(
					1,
					Enum.EasingStyle.Exponential,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				), 
				{Size = 0}
			)
			StarterGui:SetCore("TopbarEnabled", true)

		end
	end
end)

Not familiar with the new icons, and it’s a rather obvious question, but what sort of script is CharacterScript? Ensure it is actually a local script

CharacterScript is a normal script

I think it may need to be a local script, as the Blur is created on the client, not the server

Should i just use Reclass and change the Bind script to a serverscript so they will match?

Should be fine to use ReClass, yeah

It worked! Have a great night! :D

Oh noes… Now when i select a character THEN select a character, the blur wont remove…

it literally just duplicated the blureffect when you clicked the button, that’s why it’s not working.

use the command below

game:GetService("Lighting"):WaitForChild("UIBlur")