I am working on a singleplayer game and I want to create a flashlight, but the script I am using doesn't work.
Error: ServerScriptService.Other.FlashlightSetup:5: attempt to index nil with 'WaitForChild'
local players = game:GetService("Players")
local function createFlashlight()
local character = game.Workspace:FindFirstChildWhichIsA("Model")
local torso = character:WaitForChild("Torso") -- attempt to index nil with 'WaitForChild'
local light = Instance.new("PointLight", torso)
light.Name "flashlight"
light.Color = "White"
light.Enabled = false
light.Brightness = 30
end
players.PlayerAdded:Connect(createFlashlight)
