Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a first person light that follows direction a player looks?

hi guys i have been looking around for so examples for a code and could not find any so have came here to ask, i am making a game where it is pitch dark and is a FPS that would require the player to have a torch that would be toggled via key, but the problem i am having is i need the torch to follow where the player looked e.g if a player looks up to a wall the light will follow up the wall but the light is not a tool.

Could someone help me with this and provide some snippets of code so i can learn from them for future uses. Thank you for you time.

1 answer

This is NOT a request site! Do NOT request CODE to be created for you. Since I feel like being nice today, lol, here is a type of code I used in my previous games for "PointLight" inside of a Characters Head. This script runs in Workspace. Once a player joins, the script inserts a pointlight into the charatcers head. Happy Building!

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local a = Instance.new("PointLight", char.Head)
a.Range = 16 --Replace x with how far you want the glow to be
a.Brightness = 0.5 --Replace x with how bright you want it to be
a.Color = Color3.new(255, 255, 255) --Set the color you want it to be (RGB value divided by 255)
a.Shadows = true --Do you want the light to be seen through bricks?
end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.