Currently, I am trying to produce a tutorial interface that will pop up on the player’s screen, but with a “plot twist”. If the player clicks “Skip” or any button called “No”, the interface won’t ever show it again after rejoining the experience/game.
The thing is that I don’t know how it is possible to make this come true. Despite trying to find numerous searches online, no one ever asked about this… I suppose it must have to do with the player’s data, right?
If anyone can help me out with this, it will help me and other developers who want to do projects with these types of tutorial systems!
Well, you have to create a datastore (Data Stores | Documentation - Roblox Creator Hub) or use one that you already created to keep track of the player’s information. Basically, when the player clicks your button (“Skip” or “No”), you will send an event to the server through a RemoteEvent (Remote Events and Callbacks | Documentation - Roblox Creator Hub), and you will change something in the datastore.
For example, you can have a new datastore where you store for each player a bool value (true of false). If it’s their first time playing, you set it to false.
When player joins, the server sends them through RemoteEvent the value from the datastore (true of false), and you show the tutorial if the value is false. When player presses “Skip” or “No” button, you send the RemoteEvent to the server, and the server will change the value to true in the datastore.
It all depends on how you want your data to look like, but this is the easiest example I could think of. Of course, if you already have a datastore storing many things for the player, you could just add this one to the datastore.
You have to use datastores to achieve this functionality.
ServerScriptService:
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local promptedPlayersDataStore = DataStoreService:GetDataStore("PromptedPlayers")
local PromptEvent = Instance.new("RemoteEvent")
PromptEvent.Name = "PromptEvent"
PromptEvent.Parent = ReplicatedStorage
game.Players.PlayerAdded:Connect(function(player)
local playerId = player.UserId
local hasPrompted = false
local success, prompted = pcall(function()
return promptedPlayersDataStore:GetAsync(tostring(playerId))
end)
if success then
hasPrompted = prompted
else
warn("Error while fetching player data:", prompted)
end
if not hasPrompted then
PromptEvent:FireClient(player)
promptedPlayersDataStore:SetAsync(tostring(playerId), true)
end
end)
StarterPlayerScripts:
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local PromptTutorialGui = PlayerGui:WaitForChild("PromptTutorial")
local PromptEvent = game.ReplicatedStorage.Events:WaitForChild("PromptEvent")
local Yes = PromptTutorialGui.Frame:WaitForChild("Yes")
local No = PromptTutorialGui.Frame:WaitForChild("No")
PromptEvent.OnClientEvent:Connect(function()
PromptTutorialGui.Enabled = true
Yes.MouseButton1Click:Connect(function()
PromptTutorialGui.Enabled = false
end)
No.MouseButton1Click:Connect(function()
PromptTutorialGui.Enabled = false
end)
end)
These scripts should make it so that the first time a player joins the game, they will be prompted for the tutorial GUI. If the player says No or Yes, the tutorial Gui will disappear from their screen. If they rejoin, it won’t show the tutorial Gui. This is an example of my own functionality, if you want the Gui to only to disappear when they say no, you can edit the functionality to do that. I have not tested these scripts.
If you want it so that the Gui only goes away when the player says no, and stays gone, you should do the same concept except run a remoteevent after the player mousebutton1’s on the “no.”
Okay, so… I made a few changes and reorganized the script following what I have on my Roblox baseplate and the other parts, and as I click on the TextButton, nothing happens…
No issues were of any scripts were printed on the Output tab…
Did you correct adjust the script so it’d work for the hiarchy of your Gui?
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local PromptTutorialGui = PlayerGui:WaitForChild("TutorialInterface")
local PromptEvent = game.ReplicatedStorage.Events:WaitForChild("PromptEvent")
local Yes = PromptTutorialGui.GroupBackgroundInterface.Ring.Interface:WaitForChild("Option1")
local No = PromptTutorialGui.GroupBackgroundInterface.Ring.Interface:WaitForChild("Option2")
PromptEvent.OnClientEvent:Connect(function()
PromptTutorialGui.Enabled = true
Yes.MouseButton1Click:Connect(function()
PromptTutorialGui.Enabled = false
end)
No.MouseButton1Click:Connect(function()
PromptTutorialGui.Enabled = false
end)
end)
Is the Gui in startergui? If you can confirm everything I can test why it wouldn’t work later.