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

SIngle Player camera light?

Asked by 8 years ago
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

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? NotsoPenguin 705 — 8y
0
Oh thanks... how do i mark a question as answed? tanoflame 22 — 8y
0
Somebody has to make an answer, which you can mark as the answer iaz3 190 — 8y
1
Might I suggest Parenting the part to CurrentCamera under workspace, that way the brick is only seen by the player? M39a9am3R 3210 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
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

Ad

Answer this question