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

How do I make a flashlight like this?

Asked by 5 years ago

What I want to replicate: https://youtu.be/bWK0T6Femug

I know basic scripting, and this looks as if it's just a gui and a pointlight. I can do the scripting for something like this probably, but I just want a confirmation that my guess is correct.

0
This is a Pointlight, though not a GUI. The Pointlight is actually positioned relative to the CurrentCamera for this effect. Ziffixture 6913 — 5y
0
@Feahren Do you have any idea on how I could do this? theGoodpancake 5 — 5y
0
I’d assume using RenderService’s RenderStepped Signal to tie a Listener refreshing the PointLight to face the direction of the CurrentCamera’s CoordinateFrame. Ziffixture 6913 — 5y
0
It would be best to use a Part to replicate the CoordinateFrame and attach the PointLight to it instead. Ziffixture 6913 — 5y
View all comments (3 more)
0
I suggest looking both of CameraManipulation and RenderService get a better understanding Ziffixture 6913 — 5y
0
Somewhat like the Script I posted below Ziffixture 6913 — 5y
0
If the Script does work, accept it:) Help me Help you! Ziffixture 6913 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

From the observation I gave with the provided Video, I will assure you it’s not a GUI, though to me it seems like the PointLight is being projected relatively to the CurrentCamera of the LocalPlayer.

The best way I’d assume this was achieved was having a Part imitate the current CoordinateFrame of the Camera, and having a PointLight attached to the Part.

To get the smoothest function to refresh the Part’s CoordinateFrame relative to the Camera’s, I’d use RenderService’s RenderStepped Signal, as it fires every Rendered Frame.

local Player = game:GetService("Players").LocalPlayer
local Camera = workspace.CurrentCamera
local Part = workspace.Part --// Preferably CanCollide is off and the Transparency is 0.

Part.Parent = Camera

local RenderService= game:GetService("RenderService")
local Stepped = RenderService.RenderStepped:Connect(function()
   if not (Part) then Stepped:Disconnect() --// If for some reason the Part becomes nil, it’s best to not leave a pointless function running every frame.
   Part.CFrame = Camera.CFrame
end)
0
This is the closest I can get you, I can do some more experimenting though, and maybe repost. If this does work, don’t forget to accept this answer! Ziffixture 6913 — 5y
Ad

Answer this question