Struggle to blind a player with RemoteEvent

Hey guys, it’s agKing here and today I have a problem in which I struggle to blur player vision so basically I have 2 effects in the lightning in which one is for the ligh and the other is for bluring so here are the 2 effects

Capture

Here’s the code from getNearestPlayer() and the code for sending the remote event to the player what we want to blind

local function getNearestPlayer(originPlayer, maxDistance)
	local originCharacter = originPlayer.Character
	if not originCharacter then return nil end

	local originRootPart = originCharacter:FindFirstChild("HumanoidRootPart")
	if not originRootPart then return nil end

	local originPos = originRootPart.Position
	local closestPlayer, closestDist = nil, math.huge

	for _, player in pairs(game.Players:GetPlayers()) do
		if player ~= originPlayer and player.Character then
			local targetRootPart = player.Character:FindFirstChild("HumanoidRootPart")
			if targetRootPart then
				local targetPos = targetRootPart.Position
				local dist = (targetPos - originPos).Magnitude

				if dist < closestDist and (not maxDistance or dist <= maxDistance) then
					closestPlayer, closestDist = player, dist
					
					print("Type of closestPlayer:", typeof(closestPlayer)) 
					print("ClassName of closestPlayer:", closestPlayer.ClassName) 
					

					
				end
			end
		end
	end

	return closestPlayer
end

ObjectItems.Events.BlindSomeone.OnServerEvent:Connect(function(player)
	local closestPlayer = getNearestPlayer(player, math.huge)
	if closestPlayer and closestPlayer:WaitForChild("IsParticipating").Value == true then
		print("Nearest player is :", closestPlayer.Name)
		
		print("CLOSEST PLAYER IS : ", closestPlayer)
		print("PLAYER IS : ", player)
		
		ObjectItems.Events.BlindSomeone:FireClient(closestPlayer)	
	else
		print("No Player has been found")
	end
end)

2 Likes

So what’s the problem? You never specified that

3 Likes

you need to create a RemoteEvent in ReplicatedStorage to send the blur effect to the client. The code you provided fine, just add a client side script to handle the blur effect when the RemoteEvent is triggered.

take this is an example:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local blurRemote = ReplicatedStorage:WaitForChild("BlurRemoteEvent")

local blurEffect = Instance.new("BlurEffect")
blurEffect.Parent = game.Lighting
blurEffect.Size = 0  -- Start with no blur

blurRemote.OnClientEvent:Connect(function()
blurEffect.Size = 25 --your preferred value

 wait(5)  -- 
 blurEffect.Size = 0  -- Remove the blur
end)
1 Like

Problem is the 2 effects aren’t applying on the nearest player when clicking once the item is equiped.

I forgot to send the client script my apology

Events.BlindSomeone.OnClientEvent:Connect(function()
	print("SOMEONE TRIES TO BLIND ME")
	
	local effectA = Lighting["EFFECT A"]
	local effectB = Lighting["EFFECT B"]
	
	effectA.Enabled = true 
	effectB.Enabled = true

	task.delay(5, function()
		effectA.Enabled = false
		effectB.Enabled = false
	end)
end)
2 Likes

Well this part looks okay,
Is it printing?

If yes; try enabling the effects in studio while playing, do they work? is something turning them off?
If no; double check if the events are the same, is the correct player printing?

1 Like

Let me see if it’s printing on my screen.

No it’s not printing in the opponent player I want to blur

1 Like

I think I forgot to use :WaitForChild() since we are in clients man

Events.BlindSomeone.OnClientEvent:Connect(function()
	print("SOMEONE TRIES TO BLIND ME")
	
	local effectA = Lighting:WaitForChild("EFFECT A")
	local effectB = Lighting:WaitForChild("EFFECT B") 
	
	effectA.Enabled = true 
	effectB.Enabled = true

	task.delay(5, function()
		effectA.Enabled = false
		effectB.Enabled = false
	end)
end)

It’s not that I tried putting effects in parameter in the server side of remote event

The correct player is printing but I don’t understand how it’s not recognizing it as a Player Instance

" I don’t understand how it’s not recognizing it as a Player Instance"

What do you mean by this?

It means that closestPlayer that I want to blind is a valid player instance but somehow the code doesn’t want to send the request to the client of the closestPlayer but when I do it on my own player it works perfectly fine but I don’t want to target my own player because I’m the attacker

How exactly are you doing it to yourself?

Writing this

it makes myself blind but when I do this

It does nothing at all man

Are you in the HiddenDevs server? I think this problem is better resolved over stream

I’m not in hidden devs man can you invite me ?

It’s public. Search “HiddenDevs Discord” and you’ll find the invite link. @ me in the “code-help” channel as “Ziffix”, and I’ll hop on

DM me theautismgenius it’s my name on discord

I see you’re in the HiddenDevs server now. I’m waiting in the “private-3a” voice channel

Yo I’m back I was eating man let’s get back in business

When I tried experimenting, I managed to get what you want working.

-- local script
game.Lighting.Blur.Enabled = true
task.wait(5) -- blurs you for 5 seconds
game.Lighting.Blur.Enabled = false

the response aro gave should’ve worked because you only need to define the effects in the local script.