Help on Page Collecting System

Hello!

I want to make a page collecting system, I already worked on the page script.
I want it so that when every page is collected (8/8), they all respawn in random locations, and then a number between 8 and 12 will be chosen to select the amount of pages that will have to be collected next time.

Here is the page script:

local page = script.Parent

local click = page.ClickDetector

local pagenumber = game.StarterGui.StatsGui.PageNumberLabel

local function CollectPage()

page.Transparency = 1

script.Collect:Play()

click:Destroy()

end

click.MouseClick:Connect(CollectPage)

I want the text label to add up too, like 1/8 or 5/8. I don’t know how to setup the respawning script as well as the random spawning.

For the text label, make a Folder in Workspace for the pages and Name it “Pages”. (Put the pages in there, and make sure to spawn them there when they respawn)

Then, you could add a value inside the player. (New Script in SSS)

game.Players.PlayerAdded:Connect(function(player)

local PlayerStats = Instance.new("Folder")
PlayerStats.Name = "PlayerStats"
PlayerStats.Parent = player

local Pages = Instance.new("IntValue")
Pages.Name = "Pages"
Pages.Parent = PlayerStats
end)

Then, inside the script you have, inside the function, do:

player.PlayerStats.Pages.Value += 1
pagenumber.Text = player.PlayerStats.Pages.Value.."/"..#workspace.Pages:GetChildren()
1 Like

This is simple.

local Page = script.Parent

local NumberChosen = math.random(8,12)

local PageTable = {}

for i = 1,NumberChosen do
local NewPage = Page:Clone()
NewPage.Name = "Page_"..tostring(i)
PageTable[i] = NewPage
end

Now heres what you can do for position.
Take Parts and Place them randomly Across the Map.those parts will act as place holders. Now Once you have created about ~19 Parts (make sure they all have different rotation or it will be boring and make sure they are on ground.) Make a folder in workspace and Name it “PagePlaceholders”.next just put all thr parts in it and make sure they have these properties :

Transparency = 1
CanCollide = Off
Anchored = True.

Next make paste this below the above script.

local PagePlaceholders = Workspace.PagePlaceholders

for i,v in PagePlaceholders:GetChildren() do
if #PageTable ~= 0 then
local ChosenPage = math.random(1,NumberChosen)
PageTable[ChosenPage].CFrame = v.CFrame
table.remove(PageTable,ChosenPage)
NumberChosen = #PageTable
end

for Changing the Text Label just do this before the above

local Text --= Whereever your text is..

Text.Text = "0/"..tostring(NumberChosen)

Hi!

I’m sorry, I don’t understand a lot but the pages wouldn’t load in the place holder spots and the text still says “0/8” whenever I test it

Oh hey i forgot that there is a tini tiny issue with the script i provided for cloning. Please change it to this (only tht part ):-

for i = 1,NumberChosen do
local NewPage = Page:Clone()
NewPage.Name = "Page_"..tostring(i)
NewPage.Parent = workspace --this line was missing
PageTable[i] = NewPage
end

and i though that to make it easier i make you a function so this should be your final function

function CreatePages()
local Page = --wherever the page is
local CS = game:GetService("CollectionService")
local PageFolder = workspace.PageFolder or Instance.new("Folder",{Name = "PageFolder",Parent = workspace})
local NumChosen = math.random(8,12)
for i = 1,NumChosen do
local NewPage = Page:Clone()
NewPage.Name = "Page-"..tostring(i)
CS:AddTag(NewPage,"Page")
NewPage.Parent = workspace
end

local PagePlaceholders = --wherever your placeholders are. Should be folder
local PageTable = CS:GetTagged("Page")
for i,v in PagePlaceholders:GetChildren() do
if #PageTable ~= 0 then
local ChosenPage = math.random(1,NumberChosen)
PageTable[ChosenPage].CFrame = v.CFrame
table.remove(PageTable,ChosenPage)
NumberChosen = #PageTable
end

print("Created Pages")
end