Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a main menu that only appears when the player joins the game for the first time?

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

2 answers

✓ Accepted answer

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)

2 comments

0

Also you can use badge and then test if player have it

0

That costs Robux

hey you! have you ever heard of enes? if you are in trouble, better call enes!

This discussion is preserved as it was. New answers, comments, and votes are closed.