How do I put functions inside a table?

Let’s first get onto the issues of how you are accesing UI’s. In order for your changes to be seen by the server and the client, you need to change properties of the players PlayerGui, effecting UI’s inside of the StarterGui will not replicated since when a player joins all GUI inside of StarterGui is cloned and parented to the players PlayerGui.

The example below will show you the base of where you should be calling for a players UI.

Example:

local PlayerGui = player:FindFirstChild("PlayerGui")

As mentions by @UltChowsk you are setting your questlist variable twice, so this should be erroring for you when you try and clone the object.


As for the problem with your functions, since you are creating a variable each time the loop runs, the functions get called automatically. You also are not waiting before you are running the function at the end of your script, so on server startup when the event is fired it will run instantly.

I would also for the future advise against using while true do loops inside of an event

This should be a solution, remember to change your variable.

----------------------------------------------------------------
--	CHANGE VARIABLES TO INSIDE THE EVENT AND USE PLAYERGUI 	  --	
----------------------------------------------------------------

local function bandit()		
	print("Bandit!")
end

local function looter() 
	print("Looter!")
end
	
local questlist = {bandit, looter} -- Only variables are added, removed () because that will run the functions

Quest.OnServerEvent:Connect(function(player, gui)
	while true do
		local Random = math.random(5, 15)
		local PickedQuest = math.random(1, #questlist)
		
		wait(Random)
		questlist[PickedQuest]()	
	end
end)
25 Likes