I’m making a horror game and it may be pretty long, so I tried to use “Chapters” as a way of making it easy to access if a player wants to replay a certain part, but there is a few issues.
What I want for this, is having a way to make “Locked and Unlocked” Chapters within a game using gui’s and also leaderstats using a Datastore.
Or for quick reference, the chapter selection in @terribleblox’s game, “It Lurks” When you Play you can chose chapters, and you can only play certain chapters once you reached a certain point in the game, and if you didn’t you can’t…
That is what I am aiming for.
I already have a main menu with three chapters (Tests) and also a Datasave and Datastore function
MainMenu script: (Not really useful but whatever)
Chapter1:TweenPosition(
UDim2.new(0.144, 0,0.437, 0), -- ORIGINAL - 0.144, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
wait(0.025)
Chapter2:TweenPosition(
UDim2.new(0.394, 0,0.437, 0), -- ORIGINAL - 0.394, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
wait(0.025)
Chapter3:TweenPosition(
UDim2.new(0.648, 0,0.437, 0), -- ORIGINAL - 0.648, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
wait(1)
BackButton:TweenPosition(
UDim2.new(0.024, 0,0.872, 0 ), -- ORIGINAL - -0.13, 0,0.872, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.65
)
BackButton.MouseButton1Click:Connect(function()
BackButton:TweenPosition(
UDim2.new(-0.13, 0,0.872, 0), -- ORIGINAL - 0.024, 0,0.872, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.65)
wait(1)
Chapter1:TweenPosition(
UDim2.new(0.144, 0,1.08, 0), -- ORIGINAL - 0.144, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
wait(0.025)
Chapter2:TweenPosition(
UDim2.new(0.394, 0,1.08, 0), -- ORIGINAL - 0.394, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
wait(0.025)
Chapter3:TweenPosition(
UDim2.new(0.648, 0,1.08, 0), -- ORIGINAL - 0.648, 0,1.08, 0
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.75)
DataStore Script:
`local DataStoreService = game:GetService(“DataStoreService”)
local myDataStore = DataStoreService:GetDataStore(“myDataStore”)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
local Chapter = Instance.new("IntValue")
Chapter.Name = "Chapter"
Chapter.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-Chapter")
end)
if success then
Chapter.Value = data
else
print("Data Not Saved")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-Chapter",player.leaderstats.Chapter.Value)
end)
if success then
print("Data Saved")
else
print("Data Not Saved")
warn(errormessage)
end
end)
`
I tried everything I could, using extra frames, detecting the players leaderstats Values, and trying to use that, using other posts of guis and nothing has worked, so any help is apreciated : )
PS: If you are sending in code, can you try to roughly explain it please? Thanks
(Sorry if there are spelling errors, I was in a rush)