I have been seeing many people wondering about how to make a flashlight with a ring and follows the player camera like Apeirophobia, I have created a module that is open source just for that. Mind you this would be ALOT better with ray casting but I didn’t add it. I made it very very easy to use as well. The requirements needed for this is Basics of Module Scripts and Future lighting.
-- Local Script in startercharacterscripts --
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart") -- any object
local FlashlightModule = require("LOCATION OF MODULE") -- People that have no knowledge of module scripts always mess up on this part. This tutorial was made for the people who have knowledge but I'll cover this any ways. If your module is placed in the local script put "require(script:WaitForChild("FlashlightModule"))" and that's it.
local UIS = game:GetService("UserInputService")
local On = false
local db = false
local function Emission()
if not db then
db = true
if not On then
if Humanoid.Health > 0 then
On = true
FlashlightModule.CreateFlashlight(HRP)
game.ContextActionService:SetTitle("Flashlight", "Off")
end
else
if Humanoid.Health > 0 then
On = false
FlashlightModule.RemoveFlashlight(HRP)
game.ContextActionService:SetTitle("Flashlight", "On")
end
end
wait(1)
db = false
end
end
Humanoid.Died:Connect(function()
if On then
FlashlightModule.RemoveFlashlight(HRP)
end
end)
game.ContextActionService:BindAction("Flashlight", Emission, true, Enum.KeyCode.F or Enum.KeyCode.ButtonB)
game.ContextActionService:SetPosition("Flashlight", UDim2.new(0.2, 105,0.2, 0))
game.ContextActionService:SetTitle("Flashlight", "On")
** Working Flashlight Script **
Video Demonstration:
Test Place:Game
(There are next bots in the game!)
Most of all, please enjoy this module and like it!
UPDATE: The “jitteriness” is not from the module itself but the game’s lighting. Tweak the shadow properties a bit and It will look better.
This flashlight runs completely on CLIENT SIDED* (made a mistake). If it ran server sided everyone would see the players flashlight follow their camera. That’s why it is your decision to add your OWN server sided flashlight coming from the players torso.
First of all, I want to say that this is an epic module and thanks for open sourcing it.
Quick question, is there any way to fix the “Buggyness” of it?
In the video, and in my test world, the light is glitchy.
I was thinking about it for a while, how to make a light that does not bug.
What if there was a imageframe (Covering the whole screen), when you have the light off, its a semi-transparent solid image, then when the light is on, there is a little “Cutout” in the middle.
This combined with a light might give a better result. Very unsure though… just wanted to double check I am not missing something before I spend ages trying to get my theory to work.
I wouldn’t like images. In games like apeirophobia you can see the “jitteriness” of the ring. They cover it up by adding a walk animation to the light.
PS: Also the jitteriness of the looking can be covered up by tween or lerp speed. But yeah, glad most of you are liking this post. Keep liking so more people can come upon this post
Did the LocalScript in StarterCharacterScripts update? I did everything right but it shows in my Console that ‘Attempted to call require with invalid argument(s).’
EDIT: I forgot i placed FindFirstChild instead of WaitForChild.
This an amazing module btw so thank you for open sourcing it. I am curious how you would make this server sided as I have been experimenting around with this module and the only way I can think of doing it would be to send the players camera CFrame with remote events every .2 seconds or so to update the light part. Is there a better method to replicate this?
Instead of loops try using RunService. It is way more optimized and doesn’t hurt performance as much as while loops do. RunService updates with the frames you see so it would be smooth
The localscript already supports mobile, console, pc, and vr so you don’t need to do anything but if you want you can make it better. I have no issues with that!