I just know the very basics of Lua since I didnt studied much this language. And what I was trying to do is to make a gui pop up in your screen only the first time you join the game. Dying or rejoining the game wouldnt trigger the gui to pop-up. It seems like the code reset when I die or I leave the game
I know my code sucks please dont judge
local no2x = 0 -- Variable to not allow the gui pop-up again local Frame = script.Parent.Welcome -- The gui local Button = script.Parent.Button -- The close button if no2x == 0 then -- Code to execute if "no2x" is 0 Frame.Visible = true Button.Visible = true else if no2x == 1 then -- Code if "no2x" isnt 0 Frame.Visible = false Button.Visible = false if no2x == 1 then -- Output to see if the code is working print("no2x set to 1") Button.MouseButton1Click:Connect(function() no2x = 1 -- Set "no2x" to 1 when the button is clicked end) end end end
I added the commentaries while writing this to make it easier to understand the code. Anyways if you know the fix for this crappy code I would thank you so much! Thanks for reading.
To make the Gui not popup after you join you have to use DataStoreService
You also had some errors in your script but I fixed them. :)
local no2x = 0 -- Variable to not allow the gui pop-up again local Frame = script.Parent.Welcome -- The gui local Button = script.Parent.Button -- The close button local DSS = game:GetService("DataStoreService"):GetDataStore("SaveGuiScreen") while true do if no2x == 0 then -- Code to execute if "no2x" is 0 Frame.Visible = true Button.Visible = true end if no2x == 1 then -- Code if "no2x" isn't 0 Frame.Visible = false Button.Visible = false end if no2x == 1 then -- Output to see if the code is working print("no2x set to 1") end Button.MouseButton1Click:Connect(function() no2x = 1 -- Set "no2x" to 1 when the button is clicked end) Player.PlayerRemoving:Connect(function() DSS:SetAsync(Frame, Frame.Visible) end) end
I hope this helps! Please tell me if I made any errors :)