Need help with a script

Thanks to the help of some people I managed to get a FNaF Animatronic AI sort of thing script working. However I want it so when you shine the light, and he’s there, it plays a sound. Code:

– Animatronic AI

local Server = workspace:WaitForChild("Server")
local Time = Server:WaitForChild("Time")
local Enabled = false

while true do
	if Time.Value >= 12 then
		task.wait(5)
		ServerStorage.CheckersWalk1:Clone().Parent = workspace

		if workspace:FindFirstChild("Animatronics"):FindFirstChild("Checkers") then
			workspace.Animatronics.Checkers:Destroy()
		end

		task.wait(5)
		if workspace:FindFirstChild("CheckersWalk1") then
			workspace.CheckersWalk1:Destroy()
		end

		if math.random(1, 20) == 1 then
			ServerStorage.CheckersWalk3:Clone().Parent = workspace
		else
			ServerStorage.CheckersWalk2:Clone().Parent = workspace
		end

		task.wait(5)
		if workspace:FindFirstChild("CheckersWalk3") then
			workspace.CheckersWalk3:Destroy()
			ServerStorage.CheckersWalk4:Clone().Parent = workspace
                         _G.CheckersAtDoor = true
        elseif workspace:FindFirstChild("CheckersWalk2") then
			workspace.CheckersWalk2:Destroy()
			ServerStorage.CheckersWalk3:Clone().Parent = workspace
		end
	end
end```

-- Light Script:

```script.Parent.LightButton.ClickDetector.MouseClick:connect(function()
	script.Parent.LightButton.Sound:play()
	if script.Parent.Light.PointLight.Brightness == 2 then
		script.Parent.Light.PointLight.Brightness = 0
		script.Parent.Light.Sound.Volume = 0
        _G.Light1Enabled = 10
		game.Workspace.Server.Power.Usage.Value = game.Workspace.Server.Power.Usage.Value - 1
		game.ReplicatedStorage.Remotes.UpdateUsage:Fire("Light1Disabled")
	elseif script.Parent.Light.PointLight.Brightness == 0 then
		script.Parent.Light.PointLight.Brightness = 2
		script.Parent.Light.Sound.Volume = 1
		_G.Light1Enabled = 9
		game.Workspace.Server.Power.Usage.Value = 
                game.Workspace.Server.Power.Usage.Value + 1
		game.ReplicatedStorage.Remotes.UpdateUsage:Fire("Light1Enabled")
            if _G.CheckersAtDoor == true then
                      -- Play sound
                end
           end
	end
end)```

Is there a way to achieve this same thing without global variables?

Have you got your Sound object in the game yet? If so, you’ll just need to define it in your script and call :Play() in your if statement.

if _G.CheckersAtDoor == true then
    -- Play sound
    Sound:Play()
end

I do. I just want to achieve this without a global variable (e.g _G.GlobalVariableName)

You could create a boolean attribute in Workspace or use a BoolValue