#Light object not showing up via local script

1 messages · Page 1 of 1 (latest)

rough grail
#
local Players = game:GetService("Players")
local player = Players.LocalPlayer

player.CharacterAdded:Connect(function(character)
    task.wait(1)

    local head = character:WaitForChild("Head")

    local light = Instance.new("PointLight")
    light.Name = "AttachedLight"
    light.Range = 50
    light.Brightness = 30
    light.Color = Color3.new(1, 1, 1)
    light.Parent = head
end)
#

when i play test, the light doesent show

cloud hinge
#

Where you put local script?

#

StarterGui?

cyan oyster
#

@rough grail what do you think will happen to this script wehn the character loads before the local script?

rough grail
cyan oyster
#

Inside the function?

rough grail
#

Yes? Or does task.wait doesn't work in functions?

cloud hinge
#

`local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded()

task.wait(1)

local head = character:WaitForChild("Head")

local light = Instance.new("PointLight")
light.Name = "AttachedLight"
light.Range = 50
light.Brightness = 30
light.Color = Color3.new(1, 1, 1)
light.Parent = head`

Now this work

visual patio
rough grail
#

Oh, just removing the function makes sensei guess, since local script runs as soon as player joins

visual patio
#

Yk

cloud hinge
cyan oyster
#

I was trying my best to teach him and he just sends the whole scriptevilcat

cyan oyster
#

I still dont think he fully understood why this isnt working

opal elm
#

hello