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
01 | game.ReplicatedStorage.ObjectiveChanged.OnServerEvent:Connect( function (A 1 ,A 2 ) |
02 | print (A 1 ,A 2 ) |
03 | if A 2 = = "Objective1A" then |
04 | for i,v in pairs (game.Players:GetPlayers()) do |
05 | v.PlayerGui.Objective.Frame.ObjectiveText = "Great, you've gotten out of the forest. Look for a car." |
06 | v.PlayerGui.Objective.beep:Play() |
07 |
08 | if A 2 = = "Objective1B" then |
09 | v.PlayerGui.Objective.Frame.ObjectiveText = "You've found a car, now go drive off somewhere safe." |
10 | v.PlayerGui.Objective.beep:Play() |
11 | end |
12 | end |
13 | end |
14 | end ) |
Objective Changer
1 | local p = script.Parent |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:FindFirstChild( "Humanoid" ) and script.Parent.Completed.Value ~ = true then |
5 |
6 | game.ReplicatedStorage.ObjectiveChanged:FireServer( "Objective1A" ) |
7 | script.Parent.Completed = true |
8 | end |
9 | end ) |
Script In The Part That Changes The Objective
1 | local p = script.Parent |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | 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 |
5 | game.ReplicatedStorage.ObjectiveChanged:FireAllClients( "Objective1A" ) --Fires this to every client, instead of the server handling it, because the server can't access PlayerGui |
6 | script.Parent.Completed.Value = true --Sets the completed value to true. |
7 | end |
8 | end ) |
LocalScript In Objective Gui
01 | local objective = script.Parent |
02 | local frame = objective:WaitForChild( "Frame" ) |
03 | local beep = objective:WaitForChild( "beep" ) |
04 |
05 | game.ReplicatedStorage.ObjectiveChanged.OnClientEvent:Connect( function (A 1 ) --Sets up connection to the OnClientEvent, the A1 variable is what type of objective it is |
06 | if A 1 = = "Objective1A" then --Does a check for what objective it is |
07 | frame.ObjectiveText.Text = "Great, you've gotten out of the forest. Look for a car." --Change's text |
08 | beep:Play() --Play's beep |
09 | elseif A 1 = = "Objective1B" then |
10 | frame.ObjectiveText.Text = "You've found a car, now go drive off somewhere safe." --Change's text |
11 | beep:Play() --Play's beep |
12 | end |
13 | end ) |
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:
1 | local p = script.Parent |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:FindFirstChild( "Humanoid" ) and script.Parent.Completed.Value ~ = true then |
5 |
6 | game.ReplicatedStorage.ObjectiveChanged:FireServer( "Objective1A" ) |
7 | script.Parent.Completed.Value = true --instead of script.Parent.Completed = true |
8 | end |
9 | end ) |
If this is not the cause, please comment so that I can look into it further.
Hope this works for you! Merry Christmas. :)