Hi there,
I've been trying to script an object for a library that when you click on it, if you have the right requirements, it will bring up a GUI where you can change what your CurrentJob is. It works perfectly the first time, bringing up the GUI, letting me select the job I want to be currently working in, turning the GUI visible = false when I click the selection button, but then when I click the object again nothing happens. It does print "you already have the job selection GUI" and "You should now see the GUI" when I hit it the second time, clearly passing through my second 'if' statement, and there is no error, but for some reason, the GUI remains visible = false. Can anyone explain why it's doing this?
Also not sure if it matters, but one of the buttons inside the GUI triggers a remote event to change my currentjob status which seems to be working fine...
Thanks for your help!
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.Jobs.LibraryPoints.Value ~= "" and player.PlayerGui:FindFirstChild("LibraryJobSelection") == nil then
print ("you work here, but don't have the GUI selector yet")
script.Parent.LibraryJobSelection:Clone().Parent = player.PlayerGui
print ("here's a copy of the job selection GUI")
player.PlayerGui.LibraryJobSelection.Cover.Visible = true
print ("You should now see the GUI")
else if player.Jobs.LibraryPoints.Value ~= "" then
print("you already have the job selection GUI")
print("your username is "..player.Name)
player.PlayerGui.LibraryJobSelection.Cover.Visible = true
print ("You should now see the GUI")
else
print ("you do not work for the Library")
end
end
end)
EDIT: I think the issue is that I'm going from a regular script to bring up the GUI and check for rank, then the button inside has a local script that switches it off and changes the rank. It does change my rank and hide the GUI though. But when I try to make them both regular scripts, the button can't find who clicked it. Is there a way to make this a regular script and not get an error of player = nil without a click detector? Here's the local button script:
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
print (player.Name)
if player.Jobs.LibraryRank.Value == "Book Sorter"
then
print("You have the right rank")
game.ReplicatedStorage.CJBookSorter:FireServer(player)
print("remote event fired")
script.Parent.Parent.Visible = false
end
end)

2 comments
you only set it to true, never false. on line 11 and 06 you set the visible to true. perhaps you mean to set line 11 to false instead?
Well when I click the textbutton inside the GUI it would set the GUI to false.