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

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

Asked by 6 years ago

I've made this quest system and a gui brick which shows a gui for the set amount of time. I want the gui to only appear when you touch the gui brick only when the quest has been completed. I've been suggested to change the bool value and set the script to understand it by true or false but I don't want to alter the already made script.

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

script.Parent.Touched:connect(function(touchedpart)
local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent)

if player then
if player:FindFirstChild("Quest6") and player:FindFirstChild("Quest6").Value == "-[Get a Water Tank]" then
player.Quest6.Value = "-[Completed]"
game.Workspace.Data[player.Name].Socks.Value = game.Workspace.Data[player.Name].Socks.Value + 1

        end

    end

 end)

GUI Projector:

local debounce = false

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

script.Parent:clone().Parent = player.PlayerGui
wait(17)
debounce = false
player.PlayerGui.OnTouchGui:remove()
wait()
debounce = false
wait(17)
end
end


script.Parent.Parent.Touched:connect(onTouch) 

0
for your function put local connection = then your code. then after have connection:Disconnect() and it will disconnect the connection TiredMelon 405 — 6y
0
Not sure what you mean blingmcqueen 8 — 6y
0
I'll help you understand. You know to make an event work, you need to use :Connect. Now, if you don't want to not make a certain piece of code activate by an event, you use the connection(you can store this in a local variable) and use :Disconnect() saSlol2436 716 — 6y
0
For example, local brick = script.Parent local function onTouched(hit) -- code here end brick.Touched:Connect(onTouched) local connection = brick.Touched:Connect(onTouched) connection:Disconnect                                                   Here is the wiki page about it http://wiki.roblox.com/index.php?title=RBXScriptConnection#Disconnect  saSlol2436 716 — 6y
View all comments (6 more)
0
I got it but how would I link it to the quest system? blingmcqueen 8 — 6y
0
what do you mean? saSlol2436 716 — 6y
0
The GUI Projector? saSlol2436 716 — 6y
0
If you are referring to that, you would do local connection = script.Parent.Parent.Touched:Conncet(onTouch) connection:Disconnect() saSlol2436 716 — 6y
0
You could use _G or modules to use certain things in different scripts without rewriting them saSlol2436 716 — 6y
0
Both scripts are separate so how would I link them together so the projector would check if the quest was completed blingmcqueen 8 — 6y

Answer this question