Making flashlight effect on the screen

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Creating an flashlight effect around the screen like this:

  2. What is the issue? Include screenshots / videos if possible!
    I dunno how to make one like that (Video: Turning Minecraft into a Horror Game to Terrorize YouTubers - YouTube (added timestamp, no need to thanks))

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    The closest thing i got to is making the flashlight itself. But it doesn’t work in an open field area like this:

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Lighting: Horror Lighting (or as fog and night effect), Lighting Technology: Future (For enchanted lighting effect), and i’m making a horror game.

About scripting please give me an example code, please explain it briefly. About other stuff, you can bring more explain more detail.

3 Likes

I’m almost positive that you can pull this off with a Attachment or Part that is positioned in front of the head with a SpotLight casting in front of them.

1 Like

So you mean creating the spotlight in the character head ?

Try using this script:

local LightSettings = {
	Brightness = 1,
	Range = 64,
	Angle = 90
}
local HeadResponsiveness = 100 -- between 5 and 200

local Camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer
local Character = script.Parent
local Head = Character:WaitForChild("Head")

local LightPart = Instance.new("Part", Character)
LightPart.CanCollide = false
LightPart.Transparency = 1
LightPart.CFrame = Head.CFrame
LightPart.Name = "Flashlight"

local Light = Instance.new("SpotLight", LightPart)
Light.Brightness = LightSettings.Brightness
Light.Range = LightSettings.Range
Light.Angle = LightSettings.Angle

local LightAttachment = Instance.new("Attachment", LightPart)

local AlignPosition = Instance.new("AlignPosition", LightPart)
AlignPosition.Attachment0 = LightAttachment
AlignPosition.Attachment1 = Head:WaitForChild("FaceCenterAttachment")
AlignPosition.Responsiveness = 200

local AlignOrientation = Instance.new("AlignOrientation", LightPart)
AlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
AlignOrientation.Attachment0 = LightAttachment
AlignOrientation.Responsiveness = HeadResponsiveness

local Connection = Camera:GetPropertyChangedSignal("CFrame"):Connect(function()
	AlignOrientation.CFrame = Camera.CFrame.Rotation
end)

Character.Destroying:Once(function() Connection:Disconnect() end)

Put it in a LocalScript inside of StarterPlayer.StarterCharacterScripts.
In the top you can configure the light, as well as head responsiveness(basically how quickly your flashlight aligns with the camera)

Unfortunately this is only client sided, so other players won’t be able to see your light. Tell me if you need one for multiplayer, where other players will be able to see the light.

2 Likes

ah thanks, no this game is meant for single player, but if i do have the mood then this game will be coop

I think for this effect a spotlight is attached to the head/camera of the player and looks wherever the camera is looking at.

It also looks like they might be using a texture or image that’s all black but has a hole cut-out in the middle that covers the entire screen to darken the areas around the flash light more.

So you could try attaching a spotlight to the camera and using a GUI frame of a hole cut-out that covers the entire screen except the middle part where the hole is.

Thanks man i appreciate you, now i can move on with the game

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.