Hello everyone, to keep it quite simple… I made a quest system where the player has to interact with an NPC to enable a quest. However, I do NOT want the quest to be redoable or be given to the player if the player is already in progress with ANOTHER quest. How exactly would I achieve this?
I have tried using Collection Service to tag the player with “Quest” whenever they receive a quest, and when they try to do it again, it checks to see if they have that tag or not, and responds respectively. However, for some reason it didn’t quite work out.
Here is my code:
local player = game.Players.LocalPlayer
local remote = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("QuestRemote")
local remote2 = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("QuestGUI")
local remote3 = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("QuestRetake")
local AcceptQuest = script.Parent:WaitForChild("Accept")
local DeclineQuest = script.Parent:WaitForChild("Decline")
local DialogueQuest = script.Parent:WaitForChild("Dialogue")
local mainFrame = script.Parent
local function TypeWrite(textlabel, text)
for i = 1, #text do
textlabel.Text = string.sub(text, 1, i)
wait(0.010)
end
end
remote2.OnClientEvent:Connect(function(player)
if mainFrame.Position == UDim2.new(0.291, 0,0.765, 0) then
if DialogueQuest.Text == "This village might seem peaceful and harmonious from the outisde, but it is filled with wealth-lust bandits. Do you think you can help bring peace? Kill 2 Bandits." or DialogueQuest.Text == "You already have a quest in progress..." then
closeDialogue()
end
elseif mainFrame.Position == UDim2.new(0.291, 0,1.2, 0) then
openDialogue()
--if the player hasn't already done the quest then...
TypeWrite(DialogueQuest, "This village might seem peaceful and harmonious from the outisde, but it is filled with wealth-lust bandits. Do you think you can help bring peace? Kill 2 Bandits.")
AcceptQuest.Visible = true
DeclineQuest.Visible = true
for i = 1, 0.4, -0.09 do
AcceptQuest.Transparency = i
AcceptQuest.TextTransparency = i
DeclineQuest.Transparency = i
DeclineQuest.TextTransparency = i
wait()
end
AcceptQuest.MouseButton1Click:Connect(function()
remote3:FireServer()
closeDialogue()
end)
DeclineQuest.MouseButton1Click:Connect(function()
TypeWrite(DialogueQuest, "Alright then.. scram!!")
wait(1)
closeDialogue()
end)
--and if the player already did the quest then..
--DialogueQuest.Text = ""
--TypeWrite(DialogueQuest, "You already have a quest in progress...")
end
end)
function closeDialogue()
mainFrame:TweenPosition(
UDim2.new(0.291, 0,1.2, 0),
"Out",
"Quad",
1,
false
)
end
function openDialogue()
mainFrame:TweenPosition(
UDim2.new(0.291, 0,0.765, 0),
"Out",
"Quad",
1,
false
)
end