I want to make a GUI pop up when you join the game for the first time, but then never come up again. How could I make this work?
1 Like
Make sure to read the part of the script you need to change
local Data = game:GetService("DataStoreService"):GetDataStore("HasPlayed1")
local Players = game:GetService("Players")
local Connections = {}
local SpeedOfUpdate = 1; -- Time in seconds between value updates.
local function PlayerAdded(Player)
local Success, Stats, Error = pcall(function() return Data:GetAsync(tostring(Player.UserId)) end)
if not Success and Error then
warn(Error)
else
local StatFolder = Instance.new("Folder")
StatFolder.Name = "Played"
local Stat1 = Instance.new("BoolValue")
Stat1.Name = "HasPlayed"
Stat1.Value = Stats and Stats[1] or false
Stat1.Parent = StatFolder
StatFolder.Parent = Player
---------IMPORTANT PART HERE---------
while wait(SpeedOfUpdate) do
if Stat1.Value == false then
Stat1.Value = true
Player:WaitForChild("PlayerGui")["SPECIFY GUI NAME HERE"].Enabled = true
else
Player:WaitForChild("PlayerGui")["SPECIFY GUI NAME HERE"].Enabled = false
end
end
end
end
-----------------------------------------------------------------------------------------
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(function(Player)
if Connections[Player] then Connections[Player]:Disconnect() end
local Folder = Player:FindFirstChild("Played")
local Success, Error = pcall(function()
Data:SetAsync(tostring(Player.UserId),{
Folder.HasPlayed.Value,
})
end)
if not Success then
warn(Error)
else
Folder:Destroy()
end
end)
game:BindToClose(function()
wait(1)
end)
Put in serverscriptservice as a script
You can do this through the use of Datastores. When the player joins the game you can check if the player has data saved or not. If they don’t then give them the tutorial GUI.
when it says specify gui name would i delete the brackets and replace them with .?
I tried this and it didn’t work. Do you think i could make like a leader stat that you wouldn’t see since i use a custom leaderboard and then set it to 1 when you join and save it with a data store to remember if you played? And then if you haven’t played the value is 0