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

How to make an objective gui actually work?

Asked by 4 years ago

Hi, just wondering how I make an objective gui similar to undead nations one. I tried alot, but it didn't show anything.

Server Side

game.ReplicatedStorage.ObjectiveChanged.OnServerEvent:Connect(function(A1,A2)
    print(A1,A2)
    if A2 == "Objective1A" then
        for i,v in pairs(game.Players:GetPlayers()) do
            v.PlayerGui.Objective.Frame.ObjectiveText = "Great, you've gotten out of the forest. Look for a car."
            v.PlayerGui.Objective.beep:Play()

            if A2 == "Objective1B" then
                        v.PlayerGui.Objective.Frame.ObjectiveText = "You've found a car, now go drive off somewhere safe."
            v.PlayerGui.Objective.beep:Play()
        end
    end
    end
    end)

Objective Changer

local p = script.Parent

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and script.Parent.Completed.Value ~= true then

game.ReplicatedStorage.ObjectiveChanged:FireServer("Objective1A")
        script.Parent.Completed = true
end
    end)
0
`script.Parent.Completed = true` Error on line 7 of the second script User#834 0 — 4y
0
Did not work? User#22722 20 — 4y
0
Forgot to say, its local. User#22722 20 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Script In The Part That Changes The Objective

local p = script.Parent

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and script.Parent.Completed.Value == false then--Checks if this is a valid character, and if the completed value is false
        game.ReplicatedStorage.ObjectiveChanged:FireAllClients("Objective1A")--Fires this to every client, instead of the server handling it, because the server can't access PlayerGui
            script.Parent.Completed.Value = true--Sets the completed value to true.
    end
end)

LocalScript In Objective Gui

local objective = script.Parent
local frame = objective:WaitForChild("Frame")
local beep = objective:WaitForChild("beep")

game.ReplicatedStorage.ObjectiveChanged.OnClientEvent:Connect(function(A1)--Sets up connection to the OnClientEvent, the A1 variable is what type of objective it is
    if A1 == "Objective1A" then--Does a check for what objective it is
        frame.ObjectiveText.Text = "Great, you've gotten out of the forest. Look for a car."--Change's text
        beep:Play()--Play's beep
    elseif A1 == "Objective1B" then
        frame.ObjectiveText.Text = "You've found a car, now go drive off somewhere safe."--Change's text
        beep:Play()--Play's beep
    end
end)
0
Still doesn't work. User#22722 20 — 4y
0
Have you made sure that the script in the part is a Script and not a LocalScript? firestarroblox123 440 — 4y
0
And that there is a LocalScript in the Objective Gui with the LocalScript Objective Gui code? firestarroblox123 440 — 4y
0
Also I just fixed a bug, so copy the code into the scripts again. firestarroblox123 440 — 4y
View all comments (6 more)
0
Wait, what do you mean local script in the object gui with the localscript objective gui? User#22722 20 — 4y
0
Fricking legend, thank you. User#22722 20 — 4y
0
No problem! firestarroblox123 440 — 4y
0
Downvoted due to no explanation hiimgoodpack 2009 — 4y
0
Made more of an explanation, if it's good enough, I would like it if you un-downvote firestarroblox123 440 — 4y
0
You don't explain why the OP's code didn't work and what you did differently to make this one work. hiimgoodpack 2009 — 4y
Ad
Log in to vote
2
Answered by 4 years ago

I read through your scripts and found something that may be the cause of this not working.

In the objective changer script on line seven, you set what I infer is a BoolValue to true, but don't use '.Value'.

So what you would do:

local p = script.Parent

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and script.Parent.Completed.Value ~= true then

game.ReplicatedStorage.ObjectiveChanged:FireServer("Objective1A")
        script.Parent.Completed.Value = true --instead of script.Parent.Completed = true
end
    end)

If this is not the cause, please comment so that I can look into it further.

Hope this works for you! Merry Christmas. :)

0
It won't work, but you have a merry christmas aswell mate. :) User#22722 20 — 4y
0
Sorry lol. I tried my best. thanks proqrammed 285 — 4y

Answer this question