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

I have a question and i need Help!?

Asked by 3 years ago
Edited 3 years ago

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:

if script.Parent.Equipped:Connect() then
    game.StarterGui.Objectives.Frame.Framel.Objective1.Visible = false
    game.StarterGui.Objectives.Frame.Framel.Objective2.Visible = true
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.

2 answers

Log in to vote
0
Answered by 3 years ago

use

if script.Parent.Equipped:Connect() then
    game.Players.LocalPlayer.PlayerGui.Objectives.Frame.Framel.Objective1.Visible = false
    game.Players.LocalPlayer.PlayerGui.Objectives.Frame.Framel.Objective2.Visible = true
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

0
thank you OpaBohne 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
local tool = script.Parent
game.Players.PlayerAdded:Connect(function(Player)
    local PlayerGui = Player:WaitForChild("PlayerGui")
    local Objectives = PlayerGui:WaitForChild("Objectives")
    local Frame = Objectives:WaitForChild("Frame")
    local Frame1 = Frame:WaitForChild("Frame1")
    local Objective1 = Frame1:WaitForChild("Objective1")
    local Objective2 = Frame1:WaitForChild("Objective2")
    tool.Equipped:Connect(function()
        Objective1.Visible = false
        Objective2.Visible = true
    end)
end)

I haven't tested this out yet, but try it.

0
that would be more complex than it has to be, you could just use my answer if you want because it's WAY shorter, but if you are fine with this, then use it. CatastrophicDinosaur 4 — 2y

Answer this question