How would you create this

How would I make something like a region that the player can enter, and upon entering, it changes their FOV and makes sounds play. (this is for a horror game). And the closer you get to the center of the region, the more intense the effects are

7 Likes

You could use (Vector3 - Vector3).Magnitude

2 Likes

This example shows when a player enters a certain area, he will be teleported to the target part. You can modify it however you like.

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local boxCenter = CFrame.new(Vector3.new(0,0,0))
local boxSize = Vector3.new(10, 10, 10) 
local targetPart = Workspace.TargetPart 

function movePlayersToPart()
    local partsInBox = Workspace:GetPartBoundsInBox(boxCenter, boxSize)

    for _, part in ipairs(partsInBox) do
        local character = part.Parent
        if character:IsA("Model") and character:FindFirstChild("Humanoid") then
            local player = Players:GetPlayerFromCharacter(character)
            if player then
                local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
                if humanoidRootPart then
                    humanoidRootPart.CFrame = targetPart.CFrame 
                end
            end
        end
    end
end

movePlayersToPart()
2 Likes