#Objective Script changing

1 messages · Page 1 of 1 (latest)

scenic moat
#

elaborate

#

can you send the script

vast hornet
#

sure

#

thats the one that triggers if i interacted with it

#

local wash = false
local Prompt = script.Parent
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
wait(15)

            end
        end 
        print("Text changed")
else
    wash = false
    for i,plr in pairs(game.Players:GetChildren()) do
            if plr:IsA("Player") then
                local plrgui = plr.PlayerGui
                plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
            end
        end 
        print("did wrong")
end

end)

#

and i wanna turn this into that it changes the objective when 15 seconds pass by

scenic moat
#
local Prompt = script.Parent
print("variables done")

script.Parent.Triggered:Connect(function(plr)
    if wash == false then
        wash = true
        print("Wash variable done")
        for i,plr in pairs(game.Players:GetChildren()) do
                if plr:IsA("Player") then
                    local plrgui = plr.PlayerGui
                    plrgui.Objective.TextUI.Text = "Objective: Explore the House"
                    Prompt:Destroy()
                    wait(15)

                end
            end 
            print("Text changed")
    else
        wash = false
        for i,plr in pairs(game.Players:GetChildren()) do
                if plr:IsA("Player") then
                    local plrgui = plr.PlayerGui
                    plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
                end
            end 
            print("did wrong")
    end
end)```
#

looking over it

#

give me a sec

vast hornet
#

alr

opal bronzeBOT
#

studio** You are now Level 4! **studio

scenic moat
#

just use task.delay

opal bronzeBOT
#

studio** You are now Level 2! **studio

scenic moat
#

look at forums

vast hornet
#

local wash = false
local Prompt = script.Parent
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
task.wait(15)

            end
        end 
        print("Text changed")
else
    wash = false
    for i,plr in pairs(game.Players:GetChildren()) do
            if plr:IsA("Player") then
                local plrgui = plr.PlayerGui
                plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
            end
        end 
        print("did wrong")
end

end)

#

this?

scenic moat
#

no

#

hold on

#
local Prompt = script.Parent
print("variables done")

Prompt.Triggered:Connect(function(plr)
    if not wash then
        wash = true
        print("Wash variable done")

        for _, player in pairs(game.Players:GetPlayers()) do
            local plrgui = player:FindFirstChild("PlayerGui")
            if plrgui and plrgui:FindFirstChild("Objective") and plrgui.Objective:FindFirstChild("TextUI") then
                plrgui.Objective.TextUI.Text = "Objective: Explore the House"
            end
        end

        Prompt:Destroy()

        task.delay(15, function()
            for _, player in pairs(game.Players:GetPlayers()) do
                local plrgui = player:FindFirstChild("PlayerGui")
                if plrgui and plrgui:FindFirstChild("Objective") and plrgui.Objective:FindFirstChild("TextUI") then
                    plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
                end
            end
            wash = false
            print("Reset back to wash objective")
        end)

        print("Text changed")
    else
        print("Prompt already triggered. Waiting to reset...")
    end
end)```
cursive trail
#

why are you making separate forum for same problem?

vast hornet
#

because you didn't respond

scenic moat
#

i dont think its the same

#

problem

#

oh

scenic moat
#

just wait for someone else to reply

#

😭

vast hornet
#

mb

cursive trail
vast hornet
#

my bad

cursive trail
#

if you're so impatient solve it yourself or be more lazier by using chatgpt

scenic moat
#

chatgpt isnt lazy imo not aslong as you're learning by it

vast hornet
#

but theres no text label