OK so this is the script that creates a point light around the player however the problem is I want the point light to be only visible to you and not other people I cant really explain it and also I’m pretty new to coding so any help would be greatly appreciated
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local Light = character:GetChildren()
for _,x in pairs(Light) do
if x.ClassName == "Part" then
local light = Instance.new("PointLight")
light.Parent = x
light.Brightness = .015 -- Brightness
light.Range = 15 --Range Of The Light
light.Color = Color3.new(1, 0.788235, 0.6) --RGB values, 0=0 and 255=1,
light.Shadows = false
end
end
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
1 Like
Here is a screenshot of the script in action as you can see the point light is also visible to other players and I want to make the script only visible to you kinda like a fog of war type style
1 Like
Although im unsure if its the most optimised way, try placing a local script within StarterPlayerScript and making the light from there through use of Local Player?
Since its a local script, the light will only appear on the player’s screen and it wont be shown to anyone else
(Keep in mind that you cant do .PlayerAdded in this case since the player will be added before the function can begin and start taking notes of when a player is added)
Forgot to mention but because the local script will be executing while the player is still loading into the game i’d recommend having the game wait until the character variable is actually loaded through player.CharacterAdded:Wait() (Which will wait until the player character is added)
Really simple:
Make a “LocalScript” in game.StarterPlayer.StarterCharacterScripts
.
Then paste this code inside of it:
for _, v in ipairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
local light = Instance.new("PointLight")
light.Parent = v
light.Brightness = .015
light.Range = 15
light.Color = Color3.new(1, 0.788235, 0.6)
light.Shadows = false
end
end