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

SIngle Player camera light?

part = Instance.new("Part")
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.CanCollide = false
part.Locked = true

light = Instance.new("PointLight")
light.Parent = part
light.Range = 20
light.Brightness = 10

part.Parent = game.Workspace

while true do
	part.CFrame = game.Workspace.CurrentCamera.CoordinateFrame
	wait()
end

i have that but it has nothing in the output and nothing happens... Is this how i would do this?

EDIT its in a LocalScript

4 comments

0

This script works (Although slightly buggy...). Is it located in StarterGui? localscripts will only run as a descendant of player or character. Also why would you want the light to follow the camera? Why not put it in the character?

0

Oh thanks... how do i mark a question as answed?

0

Somebody has to make an answer, which you can mark as the answer

1

Might I suggest Parenting the part to CurrentCamera under workspace, that way the brick is only seen by the player?

1 answer

✓ Accepted answer
game.Players.PlayerAdded:connect(function(player) --Fires when a new player joins
	part = Instance.new("Part")  --Makes the part
    part.Size = Vector3.new(1,1,1) --Re-sizes the shape to 1,1,1
    part.Anchored = true  -- Makes the part Anchored (so it can't move until you move/change your camera.)
    part.CanCollide = true -- You can walk trough it
--  part.Locked = true -- Commented this out as it is not needed 
	part.Transparency = 1 --Makes it so you can't see it
	light = Instance.new("PointLight") -- Creates the PointLight
	light.Parent = part -- Turns the parent of the 
	light.Range = 20 --How far you can see the light
	light.Brightness = 10 -- How bright the light is
	part.Parent = game.Workspace --Moves the part to workspace so you can see it
	after() -- Fires the after function
end) -- End of function

function after() -- The After function begin
	while true do -- Makes it so it goes forever in this case as long as you dont delete the part
		part.CFrame = game.Workspace.CurrentCamera.CoordinateFrame -- Uses the current camera to show where the light will be
		wait() -- Waits half the time of wait(0) then does it all over 
	end -- End of while true do code block
end -- End of function

I commented every section so you can hopefully see what changes I made to see what fixed it :D

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