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

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

Asked by 4 years ago

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.

Closed as Not Constructive by User#24403

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
BryanFehr 133
4 years ago

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)
Ad