Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make an objective gui actually work?

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)

3 comments

0

script.Parent.Completed = true Error on line 7 of the second script

0

Did not work?

0

Forgot to say, its local.

2 answers

✓ Accepted answer

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)

10 comments

0

Still doesn't work.

0

Have you made sure that the script in the part is a Script and not a LocalScript?

0

And that there is a LocalScript in the Objective Gui with the LocalScript Objective Gui code?

0

Also I just fixed a bug, so copy the code into the scripts again.

0

Wait, what do you mean local script in the object gui with the localscript objective gui?

0

Fricking legend, thank you.

0

No problem!

0

Downvoted due to no explanation

0

Made more of an explanation, if it's good enough, I would like it if you un-downvote

0

You don't explain why the OP's code didn't work and what you did differently to make this one work.

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. :)

2 comments

0

It won't work, but you have a merry christmas aswell mate. :)

0

Sorry lol. I tried my best. thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.