How to detect if player is in a beam of Scp 316

Hello iam Sam

And now iam Trying how to make an Scp 316
I know how to make a turn on/off system

But i dont know how to detect if a player is in it beam when it is turning on
For more information u guys can ask in reply

I would appriciated Any help
Thanks for helping me !

1 Like

I don’t know what is SCP-316. I read it on the SCP Wiki and it seems to be some sort of tube, but about your problem, I think you should use raycast or a hitbox part and in a table the characters that we’re hit.

I researched what scp 316 is and it is like a floodlight thing. I am going to assume you want to know when a player enters the cone of light.

here is the loose code i came up with

local Players = game:GetService("Players")
local originPart = --origin of the light piece
local distance = 50 -- distance that a player can be effected
local lightAngle = 25 -- angle of light beam

while true do
    for _, player in pairs(Players:GetChildren()) do
        if not player.Character then return end
        local directionVector = originPart.Postion - player.Character.HumanoidRootPart.Position
        local directionUnit = directionVector.Unit
        local d = diredctionVector.Magnitude
        if d > distance then return end

        local angleFromOrigin = math.acos(originPart.CFrame.LookVector:Dot(directionUnit))
        if angleFromOrigin > lightAngle then return end

        -- run a raycast to make sure there is nothing obstructing the player from the light

        -- if the part ray hits, is a child of player, then they are in the light. do what u wish
    end
    task.wait(0.05)
end

I hope this helps.

1 Like

can i ask what return end is ?
Sorry if i ask your too many question since i want to know how to make it to make next time

if the clause is true then the return end makes then the code returns and the code after it won’t run. It is actually just

if not player.Character then 
    return 
end

just on one line to save space.

I write the code at the --Code right ?

Edit : i have to write the origin position of the light in local originpart = … right ?
Edit 2: the origin should be like this “-46, 6, 42” right ?

What should i write to only call the person That is in the beam ?

Example game.Wokspace.jfijf.Touched:Connect(function(hit)
hit.Parent in this case i can use that to only call person hit but idk how to call them in your situation if u have written them inside your script can u describe me a little bit ?