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):
01 | script.Parent.Touched:connect( function (touchedpart) |
02 | local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent) |
03 |
04 | if player then |
05 | if player:FindFirstChild( "Quest6" ) and player:FindFirstChild( "Quest6" ).Value = = "-[Get a Water Tank]" then |
06 | player.Quest 6. Value = "-[Completed]" |
07 | game.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:
01 | local debounce = false |
02 |
03 | function getPlayer(humanoid) |
04 | local players = game.Players:children() |
05 | for i = 1 , #players do |
06 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
07 | end |
08 | return nil |
09 | end |
10 |
11 | function onTouch(part) |
12 |
13 | local human = part.Parent:findFirstChild( "Humanoid" ) |
14 | if (human ~ = nil ) and debounce = = false then |
15 |
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.
01 | script.Parent.Touched:connect( function (touchedpart) |
02 | local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent) |
03 |
04 | if player then |
05 | if player:FindFirstChild( "Quest6" ) and player:FindFirstChild( "Quest6" ).Value = = false -- for for not completed |
06 | player.Quest 6. Value = true -- sets it to true/completed |
07 | game.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.
01 | local debounce = false |
02 | function getPlayer(humanoid) |
03 | local players = game.Players:children() |
04 | for i = 1 , #players do |
05 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
06 | end |
07 | return nil |
08 | end |
09 |
10 | function onTouch(part) |
11 | local human = part.Parent:findFirstChild( "Humanoid" ) |
12 | local player = game.Players:GetPlayerFromCharacter(part.Parent) -- added in for compatibility |
13 | local questbool = player:FindFirstChild( "Quest6" ).Value -- the new bool |
14 | if (human ~ = nil ) and debounce = = false and questbool = true then |
15 |
I hope this helped you in the right sense. Good luck!