-- Example trigger script


local gui = script.Parent
local playergui = gui.Parent
local player = playergui.Parent
local mouse = player:GetMouse()

local vFrequency = script.Frequency
local tikiTorches = workspace.TikiTorches:GetChildren()

local loop = false

function go()
	local torch = tikiTorches[math.random(1, #tikiTorches)]
	gui.CreateIndicator:Invoke(torch.Main.Position, 1)
end

gui.TextButton.MouseButton1Down:connect(function ()
	gui.CreateIndicator:Invoke(Vector3.new(math.random(-25,25), 0, math.random(-25,25)), 2.5)
end)

gui.TextButton.MouseButton2Down:connect(function ()
	loop = not loop
end)

while true do
	if loop then
		go()
		wait(math.random(1,vFrequency.Value)/100)
	else
		gui.TextButton.MouseButton2Down:wait()
	end
	wait()
end
