"Remote event invocation queue exhausted; did you forget to implement OnClientEvent?" Error

So I recently made a script where it emits a raycast from the humanoidrootpart and detect if there’s something above and then make snow particles invisible. It’s a script for realism and also because it’s annoying where there’s snow inside. But that’s not the issue, I’m getting this error because I made 2 collisiongroups, one for trees in the outside area of the map and the default one. I then set the raycast collision group to the default one and not the trees one but it gave me an error. Now, the snow particles are off at all times as if something is above me but there isn’t.

Here’s the script:

-- Get the particle system from the workspace
local particle1 = game.Workspace.CameraPart.ParticleEmitter
local particle2 = game.Workspace.CameraPart.ParticleEmitter2
local particle3 = game.Workspace.CameraPart.Particles

local particle4 = game.Workspace.CameraPart2.ParticleEmitter
local particle5 = game.Workspace.CameraPart2.SnowFlake
local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")

OldP1Value = particle1.Transparency
OldP2Value = particle2.Transparency
OldP3Value = particle3.Transparency
OldP4Value = particle4.Transparency
OldP5Value = particle5.Transparency

-- Define a function to check if a player is under any part using raycasting
local function checkPlayerUnderPart(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
	if humanoidRootPart then
		local raycastResult = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0,-1,0)*100)
		local RaycastParameters = RaycastParams.new()
		RaycastParameters.CollisionGroup = "Default"
		if raycastResult and raycastResult.Instance:IsA("BasePart") then
			-- Disable the particle system if the player is under a part
			replicatedEvent:FireClient(player, "disableParticle")
		else
			-- Enable the particle system if the player is not under any part
			replicatedEvent:FireClient(player, "enableParticle")
		end
	end
end

-- Connect the function to the player's character
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)
		coroutine.wrap(function()
			while wait(0.1) do
				if player.Character ~= nil then
					local character = player.Character
					local raycastParams = RaycastParams.new();
					raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
					raycastParams.FilterDescendantsInstances = {player.Character};
					raycastParams.CollisionGroup = "Default"
					local ray = workspace:Raycast(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, 15, 0) * 100, raycastParams);
					if ray and ray.Instance:IsA("BasePart") then
						-- If the player is under any part, call the function to disable the particle system
						checkPlayerUnderPart(player)
					else
						-- If the player is not under any part, enable the particle system
						replicatedEvent:FireClient(player, "enableParticle")
					end
				end
			end
		end)();
	end)
end)

And here’s the local script it runs:

local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")
local particle1 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter
local particle2 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter2
local particle3 = game.Workspace:WaitForChild("CameraPart").Particles

local particle4 = game.Workspace:WaitForChild("CameraPart2").ParticleEmitter
local particle5 = game.Workspace:WaitForChild("CameraPart2").SnowFlake
local replicatedEvent = game.ReplicatedStorage.MyCustomEvent
local tweenService = game:GetService("TweenService")

replicatedEvent.OnClientEvent:Connect(function(eventName)
	if eventName == "disableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	elseif eventName == "enableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	end
end)
2 Likes

You’re firing the event too many times. RemoteEvents have a limit to how many times you can fire them within a time period

1 Like

So what do I do now? It is a raycast after all so it should fire constantly

1 Like

You would have to do the ray casting on the client. Anything performance intensive that only affects one player and/or is used for special effects should be done client-sided

1 Like

Wait so should I turn it into a local script? Will it be able to access everything in the original script? Also is the collision group property correct?

1 Like

If it’s not something that can only be accessed from the server (and judging by your script, it doesn’t seem that way), then yes (for both questions)

Yes


Your local script should be re-structed to resemble something like:

local player = game:GetService("Players").LocalPlayer
--... raycast stuff

task.spawn(function()
   --... raycast stuff
end)
1 Like
local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")
local particle1 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter
local particle2 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter2
local particle3 = game.Workspace:WaitForChild("CameraPart").Particles

local particle4 = game.Workspace:WaitForChild("CameraPart2").ParticleEmitter
local particle5 = game.Workspace:WaitForChild("CameraPart2").SnowFlake
local replicatedEvent = game.ReplicatedStorage.MyCustomEvent
local tweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer

replicatedEvent.OnClientEvent:Connect(function(eventName)
	if eventName == "disableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	elseif eventName == "enableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	end
end)

Where do I put task.spawn in the script?

1 Like
local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")
local particle1 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter
local particle2 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter2
local particle3 = game.Workspace:WaitForChild("CameraPart").Particles

local particle4 = game.Workspace:WaitForChild("CameraPart2").ParticleEmitter
local particle5 = game.Workspace:WaitForChild("CameraPart2").SnowFlake
local replicatedEvent = game.ReplicatedStorage.MyCustomEvent
local tweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer

local function updateParticles(eventName)
	if eventName == "disableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	elseif eventName == "enableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	end
end

-- this is where you'd put the raycast function 

task.spawn(function()
  --this is where you'd put the loop
end)
1 Like

Excuse my slowness but what do I put in the raycasting function area? As of right now they’re 2 separate local scripts and the raycasting stuff is in the first one and not the second one. The second one just does a function when the event is fired.

The raycast stuff is the stuff from your first script

The Raycast function is checkPlayerUnderPart and the loop is the while loop (without the coroutinr and the events, just the loop)


Yea

Wait so do I merge scripts and just get rid of events? I’m sorry but I am so confused. Can you please write the script like how I’m supposed to?

Should it look something like this?

local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")
local particle1 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter
local particle2 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter2
local particle3 = game.Workspace:WaitForChild("CameraPart").Particles

local particle4 = game.Workspace:WaitForChild("CameraPart2").ParticleEmitter
local particle5 = game.Workspace:WaitForChild("CameraPart2").SnowFlake
local replicatedEvent = game.ReplicatedStorage.MyCustomEvent
local tweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
OldP1Value = particle1.Transparency
OldP2Value = particle2.Transparency
OldP3Value = particle3.Transparency
OldP4Value = particle4.Transparency
OldP5Value = particle5.Transparency

local function updateParticles(eventName)
	if eventName == "disableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	elseif eventName == "enableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	end
end

local function checkPlayerUnderPart(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
	if humanoidRootPart then
		local raycastResult = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0,-1,0)*100)
		local RaycastParameters = RaycastParams.new()
		RaycastParameters.CollisionGroup = "Default"
		if raycastResult and raycastResult.Instance:IsA("BasePart") then
			-- Disable the particle system if the player is under a part
			replicatedEvent:FireClient(player, "disableParticle")
		else
			-- Enable the particle system if the player is not under any part
			replicatedEvent:FireClient(player, "enableParticle")
		end
	end
end

task.spawn(function()
	game.Players.PlayerAdded:Connect(function(player)
		player.CharacterAppearanceLoaded:Connect(function(char)
			coroutine.wrap(function()
				while wait(0.1) do
					if player.Character ~= nil then
						local character = player.Character
						local raycastParams = RaycastParams.new();
						raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
						raycastParams.FilterDescendantsInstances = {player.Character};
						raycastParams.CollisionGroup = "Default"
						local ray = workspace:Raycast(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, 15, 0) * 100, raycastParams);
						if ray and ray.Instance:IsA("BasePart") then
							-- If the player is under any part, call the function to disable the particle system
							checkPlayerUnderPart(player)
						else
							-- If the player is not under any part, enable the particle system
							replicatedEvent:FireClient(player, "enableParticle")
						end
					end
				end
			end)();
		end)
	end)
end)
local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")
local particle1 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter
local particle2 = game.Workspace:WaitForChild("CameraPart").ParticleEmitter2
local particle3 = game.Workspace:WaitForChild("CameraPart").Particles

local particle4 = game.Workspace:WaitForChild("CameraPart2").ParticleEmitter
local particle5 = game.Workspace:WaitForChild("CameraPart2").SnowFlake
local replicatedEvent = game.ReplicatedStorage.MyCustomEvent
local tweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
OldP1Value = particle1.Transparency
OldP2Value = particle2.Transparency
OldP3Value = particle3.Transparency
OldP4Value = particle4.Transparency
OldP5Value = particle5.Transparency

local function updateParticles(eventName)
	if eventName == "disableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	elseif eventName == "enableParticle" then
		particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
		particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
		particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
		particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	end
end

local function checkPlayerUnderPart(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
	if humanoidRootPart then
		local raycastResult = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0,-1,0)*100)
		local RaycastParameters = RaycastParams.new()
		RaycastParameters.CollisionGroup = "Default"
		if raycastResult and raycastResult.Instance:IsA("BasePart") then
			-- Disable the particle system if the player is under a part
			updateParticles("disableParticle")
		else
			-- Enable the particle system if the player is not under any part
			updateParticles("enableParticle")
		end
	end
end

task.spawn(function()
				while task.wait(0.1) do
					if player.Character ~= nil then
						local character = player.Character
						local raycastParams = RaycastParams.new();
						raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
						raycastParams.FilterDescendantsInstances = {player.Character};
						raycastParams.CollisionGroup = "Default"
						local ray = workspace:Raycast(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, 15, 0) * 100, raycastParams);
						if ray and ray.Instance:IsA("BasePart") then
							-- If the player is under any part, call the function to disable the particle system
							checkPlayerUnderPart(player)
						else
							-- If the player is not under any part, enable the particle system
							updateParticles("enableParticle")
						end
					end
				end
end)

I’m on mobile at the moment, so I can’t properly format everything

I don’t know if it works or not yet because I have streaming enabled on and the CameraPart and CameraPart2 objects get streamed out

Ok I turned streaming enabled off and it doesn’t turn down the particle when the raycast detects an object above the player.

Ok I edited some things to make it a function that is called instead of an event firing and it still doesn’t work.

-- Get the particle system from the workspace
local CameraPart = game.Workspace:WaitForChild("CameraPart")
local CameraPart2 = game.Workspace:WaitForChild("CameraPart2")

local particle1 = CameraPart.ParticleEmitter
local particle2 = CameraPart.ParticleEmitter2
local particle3 = CameraPart.Particles

local particle4 = CameraPart2.ParticleEmitter
local particle5 = CameraPart2.SnowFlake
local replicatedEvent = game.ReplicatedStorage:FindFirstChild("MyCustomEvent")

OldP1Value = particle1.Transparency
OldP2Value = particle2.Transparency
OldP3Value = particle3.Transparency
OldP4Value = particle4.Transparency
OldP5Value = particle5.Transparency
local function disableParticle()
	particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
	particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)}
end
local function enableParticle()
	particle1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
	particle2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)}
	particle3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0.4), NumberSequenceKeypoint.new(1,0.4)}
	particle4.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
	particle5.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(1,0)}
end

-- Define a function to check if a player is under any part using raycasting
local function checkPlayerUnderPart(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
	if humanoidRootPart then
		local raycastResult = workspace:Raycast(humanoidRootPart.Position, Vector3.new(0,-1,0)*100)
		local RaycastParameters = RaycastParams.new()
		RaycastParameters.CollisionGroup = "Default"
		if raycastResult and raycastResult.Instance:IsA("BasePart") then
			-- Disable the particle system if the player is under a part
			disableParticle()
		else
			-- Enable the particle system if the player is not under any part
			enableParticle()
		end
	end
end

task.spawn(function()
	-- Connect the function to the player's character
	game.Players.PlayerAdded:Connect(function(player)
		player.CharacterAppearanceLoaded:Connect(function(char)
			coroutine.wrap(function()
				while wait(0.1) do
					if player.Character ~= nil then
						local character = player.Character
						local raycastParams = RaycastParams.new();
						raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
						raycastParams.FilterDescendantsInstances = {player.Character};
						raycastParams.CollisionGroup = "Default"
						local ray = workspace:Raycast(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, 15, 0) * 100, raycastParams);
						if ray and ray.Instance:IsA("BasePart") then
							-- If the player is under any part, call the function to disable the particle system
							checkPlayerUnderPart(player)
						else
							-- If the player is not under any part, enable the particle system
							enableParticle()
						end
					end
				end
			end)();
		end)
	end)
end)

You could make your script more dynamic instead of hardcoded, makes it easier to work with it, check this example:
(Im not sure what are your values of a particle disabled and enabled, and seems that each particle has its own properties and I didnt include that, but those values can be collected from the original values in your particleEmitter since the first loop and table creation)

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

-- Table holding all the particles
local particleTable = {}

-- Insert all particles in table
for _, particle in pairs(game.Workspace:WaitForChild("CameraPart2"):GetChildren()) do
	if particle:IsA("ParticleEmitter") then
		table.insert(particleTable, particle)
	end
end

-- the params, is not needed to create this over and over inside the loop
local raycastParams = RaycastParams.new();
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
raycastParams.FilterDescendantsInstances = {player.Character};
raycastParams.CollisionGroup = "Default"

-- a function that will disable and enable the particles
local function updateParticles(eventName)
	local numbSeq
	if eventName then
		numbSeq = NumberSequence.new{NumberSequenceKeypoint.new(0,1), NumberSequenceKeypoint.new(1,1)} -- is this disabled?
	else
		numbSeq = NumberSequence.new{NumberSequenceKeypoint.new(0,0.9), NumberSequenceKeypoint.new(1,0.9)} -- is this enabled?
	end
	
	for _, particle in pairs(particleTable) do
		particle.Transparency = numbSeq
	end
end

-- the checking loop
task.spawn(function()
	while task.wait(0.1) do
		if player.Character ~= nil then
			local ray = workspace:Raycast(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, 15, 0) * 100, raycastParams);
			if ray then
				if ray.Instance:IsA("BasePart") then
					updateParticles(true)
				end
			else
				updateParticles(false)
			end
		end
	end
end)

I replaced the script but it doesn’t seem to work

I tested it and worked good for me, but I didnt create particles for the test, Im gonna test it with particles

That’s weird because the transparency is still the same and doesn’t change while one particle’s transparency is 1 even when the raycast doesn’t detect something