I have now spent a very long time writing a script that says that if you equip this tool then in the StarterGui the visibility of an object named there in the script is set to true or false:
1 | if script.Parent.Equipped:Connect() then |
2 | game.StarterGui.Objectives.Frame.Framel.Objective 1. Visible = false |
3 | game.StarterGui.Objectives.Frame.Framel.Objective 2. Visible = true |
4 | end |
(This is a localscript in the tool)
But that never works there comes then always something with a nil value and there I wanted to ask if someone has a better script or a better idea to fix this problem.
use
1 | if script.Parent.Equipped:Connect() then |
2 | game.Players.LocalPlayer.PlayerGui.Objectives.Frame.Framel.Objective 1. Visible = false |
3 | game.Players.LocalPlayer.PlayerGui.Objectives.Frame.Framel.Objective 2. Visible = true |
4 | end |
because startergui effects the gui at the starting point, that's why it's named startergui. but for the player, it has it's own separate gui folder it uses
01 | local tool = script.Parent |
02 | game.Players.PlayerAdded:Connect( function (Player) |
03 | local PlayerGui = Player:WaitForChild( "PlayerGui" ) |
04 | local Objectives = PlayerGui:WaitForChild( "Objectives" ) |
05 | local Frame = Objectives:WaitForChild( "Frame" ) |
06 | local Frame 1 = Frame:WaitForChild( "Frame1" ) |
07 | local Objective 1 = Frame 1 :WaitForChild( "Objective1" ) |
08 | local Objective 2 = Frame 1 :WaitForChild( "Objective2" ) |
09 | tool.Equipped:Connect( function () |
10 | Objective 1. Visible = false |
11 | Objective 2. Visible = true |
12 | end ) |
13 | end ) |
I haven't tested this out yet, but try it.