Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

0
Thx !! KingAquitain 35 — 2y
0
yw sata5pa3da 286 — 2y
Ad

Answer this question