You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
A mechanism where a random quest(function) is chosen at random intervals -
What is the issue?
Functions activate immediately and is not chosen randomly at random intervals
Sadly, I’ve been toying around with this for the entire day, and it’s clear that I’m illiterate in tables…
local RS = game:GetService("ReplicatedStorage")
local Quest = RS:FindFirstChild("Quest")
local Frame = game.StarterGui.ScreenGui.QFrame
local Quests = game.StarterGui.ScreenGui.QFrame.ScrollingFrame
local questlist = game.StarterGui.ScreenGui.QFrame.QuestList
Quest.OnServerEvent:Connect(function(player, gui)
while true do
local function bandit()
local banditquest = questlist:FindFirstChild("HuntBandit"):Clone()
banditquest.Parent = gui
banditquest.Visible = true
print("Bandit!")
end
local function looter()
local lootquest = questlist:FindFirstChild("HuntLooter"):Clone()
lootquest.Parent = gui
lootquest.Visible = true
print("Looter!")
end
local questlist = {{bandit()}, {looter()}}
local Random = math.random(5, 15)
local PickedQuest = math.random(1, #questlist)
print(questlist[PickedQuest])
wait(Random)
end
end)