I want to make a main menu that will only show the first time a player plays my game but everything I tried won't work. Right now I have a bool that detects if the player has joined the game before or not and that is working but the script that hides and shows the GUI won't work.
This is the script I am using. It is a local script inside of starter player scripts.
local mainMenu = game.StarterGui.TitleScreen local onMenu = player:WaitForChild("onMenu") local isLoaded = game.ReplicatedStorage.Value if onMenu.Value == true then mainMenu.Enabled = true else mainMenu.Enabled = false end
Hello, Your LocalScript is fine!
But if we want to know if the player had joined once and is returning, whe use something called DataStore, DataStore is a service that allows you to save a table or value forever!
Create a Script in ServerScriptService and call it whatever you want
If the script works, I'd highly appreciate it if you accept my answer, otherwise if it doesn't work, comment the problem and I'll try and fix it!
Script in ServerScriptService:
local PlayersService = game:GetService("Players") local dataStoreService = game:GetService("DataStoreService") local joinDataStore = dataStoreService:GetDataStore("JoinDataStore") PlayersService.PlayerAdded:Connect(function(player) local isOnMenu = Instance.new("BoolValue") isOnMenu.Name = "onMenu" isOnMenu.Parent = player local playerJoinData = nil pcall(function() playerJoinData = joinDataStore:GetAsync(player.UserId.."-joinData") end) -- If player had joined once! if playerJoinData ~= nil then isOnMenu.Value = false print("Returning player") else isOnMenu.Value = true print("New player") end end) local bindableEvent = Instance.new("BindableEvent") PlayersService.PlayerRemoving:Connect(function(player) pcall(function() joinDataStore:SetAsync(player.UserId.."-joinData", player.onMenu.Value) end) bindableEvent:Fire() print("Saved!") end) game:BindToClose(function() while #PlayersService:GetPlayers() > 0 do bindableEvent.Event:Wait() wait() end end)
hey you! have you ever heard of enes? if you are in trouble, better call enes!