Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to activate the blur of a local player when he enters the region3 ?

Hello ! I would like to activate the blur on the localplayer when it enters the region3. My problem is that the blur is activated all the time? Can you help me? Thanks in advance ! Here is my code :

local zone = workspace.zone
local region = Region3.new(zone.Position - zone.Size/2, zone.Position + zone.Size/2)

while 5 == 5 do
	
	local parts = workspace:FindPartsInRegion3(region, zone)

	if parts ~= 0 then
		game.Lighting.Blur.Size = 24
	else
		game.Lighting.Blur.Size = 0	
	end
	wait(0.1)
	
end

1 answer

✓ Accepted answer

Firstly, the "parts" variable returns a table so it obviously won't be zero making the blur show all the time. Secondly, you are not considering if the parts in the region is not the player's character.

So code should look like this:

local player = game.Players.LocalPlayer
	local char = player.Character or player.CharacterAdded:Wait()
	local zone = workspace.zone
	local region = Region3.new(zone.Position - zone.Size/2, zone.Position + zone.Size/2)

	while 5 == 5 do

		local parts = workspace:FindPartsInRegion3(region, zone)
		
		local is_in_region = true
		for _,v in pairs(parts) do
			if v:IsDescendantOf(char) then
				is_in_region =false
			end
		end
		
		
		if is_in_region then
			game.Lighting.Blur.Size = 24
		else
			game.Lighting.Blur.Size = 0 
		end
		wait(0.1)

	end

Hope I helped.

2 comments

0

Thx !!

0

yw

This discussion is preserved as it was. New answers, comments, and votes are closed.