Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make dialogue only appear once a quest is completed?

Asked by 7 years ago

I made this quest system and along with it, a dialogue system. I made the dialogue to work so when you touch a part then a gui would pop up with a dialogue prompt. It functions fine but I only want the dialogue to appear when a specific quest has been completed.

Quest Completion Marker(for reference of how the mission becomes assigned complete):

01script.Parent.Touched:connect(function(touchedpart)
02local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent)
03 
04if player then
05if player:FindFirstChild("Quest6") and player:FindFirstChild("Quest6").Value == "-[Get a Water Tank]" then
06player.Quest6.Value = "-[Completed]"
07game.Workspace.Data[player.Name].Socks.Value = game.Workspace.Data[player.Name].Socks.Value + 1
08 
09        end
10 
11    end
12 
13 end)

Dialogue System:

01local debounce = false
02 
03function getPlayer(humanoid)
04local players = game.Players:children()
05for i = 1, #players do
06if players[i].Character.Humanoid == humanoid then return players[i] end
07end
08return nil
09end
10 
11function onTouch(part)
12 
13local human = part.Parent:findFirstChild("Humanoid")
14if (human ~= nil) and debounce == false then
15 
View all 33 lines...

1 answer

Log in to vote
0
Answered by 7 years ago

Use your ingame debounce.

It seems that you have a quest completion debounce in your game. It may be a string value or something. Try replacing it with a BoolValue instead.

01script.Parent.Touched:connect(function(touchedpart)
02local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent)
03 
04if player then
05if player:FindFirstChild("Quest6") and player:FindFirstChild("Quest6").Value == false -- for for not completed
06player.Quest6.Value = true -- sets it to true/completed
07game.Workspace.Data[player.Name].Socks.Value = game.Workspace.Data[player.Name].Socks.Value + 1
08 
09        end
10 
11    end
12 
13 end)

Now you modify your second script to use the Bool.

01local debounce = false
02function getPlayer(humanoid)
03local players = game.Players:children()
04for i = 1, #players do
05if players[i].Character.Humanoid == humanoid then return players[i] end
06end
07return nil
08end
09 
10function onTouch(part)
11local human = part.Parent:findFirstChild("Humanoid")
12local player = game.Players:GetPlayerFromCharacter(part.Parent) -- added in for compatibility
13local questbool = player:FindFirstChild("Quest6").Value -- the new bool
14if (human ~= nil) and debounce == false and questbool = true then
15 
View all 33 lines...

I hope this helped you in the right sense. Good luck!

Ad

Answer this question