This will work for an infinite amount of times right?
Yes, actually, it doesn’t gives a limited amount of quests
Here is a script which gives a bounty if you have less than 3 bounties with you:
local btn = script.Parent local count = 0 btn.MouseClick:Connect(function(plr) for i, v in pairs(plr.Backpack:GetChildren()) do if v.Name == btn.Parent.Name.."'s bounty" then count = count + 1 end end if count < 3 then game.ServerStorage.BOUNTIES:FindFirstChild(btn.Parent.Name.."'s bounty"):Clone().Parent = plr.Character end count = 0 end)
So yeah maybe it isn’t optimized but i did it some times ago
As you could see, i loop inside the Backpack to see if there is a bounty with the same name. If the script find one, it does count += 1. At the end, if the count is smaller than 3, then it gives a bounty. Else, it doesn’t
Hmm… what does this relate to?
Might be a good idea to break up these four questions into four posts next time, otherwise the discussion will get confused and out of hand.
Anyways, I’ll give some ideas for the “daily rewards question”. This isn’t the exact same problem, but it’s very similar:
Reviewing your code I see a lot of code for visuals and UI but I don’t see code interacting with datastores editing tables and information you stored for quests (After some time reading your code I come to realize you may be using folders and number values it isn’t bad it just takes away a lot of possible things you can do )
I would need more snippets of your code specifically where you add onto values like apple to make a suggestion. While I was making a suggestion… I realize how you stored your data. or assumed atleast.
What i would do (but wouldnt be helpful)
Why did i say “(but wouldnt be helpful)”? - Because the way you store data at the moment doesn’t allow editing data table aside from storing your number values (I’m assuming your datastore system is similar to using leader stats)
I would store a new table of two values (this would require a whole new system of storing data)
- First Value would be ID or name of Quest so u can identify the second value
- Second Value would be the progress value (could be a number or bool or whatever u want)
Hmm. I currently use Datastore2 to store my values. I am able to update them
Can I see how you edit your data tables? While viewing your apple changed event it seemed like something similar to a leader stats system.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local DataStore2 = require(game.ReplicatedStorage.MainModule)
--# Requiring The Module
DataStore2.Combine("Key","Apple")
--# Player Join Function:
game.Players.PlayerAdded:Connect(function(plr)
--[Defining The Different Major Datastores]--
local AppleDatastore = DataStore2("Apple",plr)
local Stats = Instance.new("Folder",plr)
Stats.Name = "Stats"
local Apples= Instance.new("IntValue",Stats)
Apples.Name = "Apple"
if AppleDatastore:Get() ~= nil then
Apple.Value = AppleDatastore:Get()
print("[Debug]" .. "AppleAmount: " .. Apple.Value)
else
Apple.Value = 0
end
Apple.Changed:Connect(function()
AppleDatastore:Set(Apple.Value)
end)
This is how I store for all my items
Its mostly what I suspected. I may be able to help but… I see that you set up a datastore for Apple. I am concerned moving forward are going to setup a datastore for each number value you need? (Just asking because i wouldnt recommend it)
Well… I do not know of any better ways so if you do I would like to learn it
I would suggest learning how to create and edit tables then I would recommend you learn how to use modules. So that you can make functions to edit your data tables within your module.
Once you know how to make datastore modules you can slowly add functionality for quest and various other systems like boosters/bonus like you wanted.
Oh I already am using modules, just simple ones to retrieve data
Possible if you could share some code on the basics on what I need to do?
If you have a module for retrieving data I would recommend you add functions for editing that data within that module unless you want to make a separate module to call the module retrieving data and edit the data
In my case I usually have
ProfileService is an open-source data auto-saving module I use like how you use Datastore2
DataStoreManager Retrieves all the player’s data when they join and stores it in a table
All my data modules require a datastore manager to retrieve data to edit
InventoryManager and StatsManager are modules i have functions in to edit data they both require Datastore manager to retrieve data before they edit like so
function StatsManager:GetData(Player)
local Profile = DataManager:GetStatisticProfile(Player)
local Data = Profile.Data
return Data
end
I used to have modules that utilized datastore2 I would have to find them to show you an example if you’d like to see (Looking for it rn)
Well, which one do you think would be better? As I want to store a large amount of items, I find it quite hard to make a datastore for each one manually. And I do come across that error quite alot " [DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 280300094]"
Here’s an example of Datastore manager (I made for a freind to use) You make a table(In this case PlayerStatistics_EXAMPLE ) for the functions to edit and to edit data you would just call on the module and call the function you want to use.
Also noticed that was better to require the module from within your game and that using this
local DataStore2 = require(1936396537)
would cause my game to yield till it found thee datastore2 module
Summary
PlayerStats_DataStore = {}
local DataStore2 = require(1936396537)-- Datastore2
local PlayerStatistics_EXAMPLE = {
Strength = 0, -- Damage Dealt, How much weight can be lifted.
Stamina = 0, -- How long you can fight without fatigue, how long you can run.
PunchingSpeed = 0, -- How fast you punch.
Speed = 0, -- How fast you run/how fast you move in the boxing ring
Endurance = 0, -- How much Health the player has
MuscleMass = 0,--(Maxes at 10)
}
function PlayerStats_DataStore:SaveStats(Player) -- PlayerStats_DataStore:SaveStats(Player) Saves Data for (Player)
local Stats = DataStore2("Change this to what ever you want", Player)
Stats:Save()
end
function PlayerStats_DataStore:GetStat(Player,Name_Of_Stat)
local Stats = DataStore2("Change this to what ever you want", Player)
local PlayerStatistics = Stats:GetTable(PlayerStatistics_EXAMPLE)
return PlayerStatistics[Name_Of_Stat]
end
function PlayerStats_DataStore:AddToStat(Player,Name_Of_Stat,Amount) -- Adds Amount onto Data Indexing(Player) and Adding(AMOUNT) to (Name_Of_Stat)
local Stats = DataStore2("Change this to what ever you want", Player)
local PlayerStatistics = Stats:GetTable(PlayerStatistics_EXAMPLE)
Stats:Update(function(PlayerStatistics)
PlayerStatistics[Name_Of_Stat] = PlayerStatistics[Name_Of_Stat] + Amount
return PlayerStatistics
end)
print(Name_Of_Stat .." : "..PlayerStatistics[Name_Of_Stat].. 'Added to '..Player.Name)
end
function PlayerStats_DataStore:SetStat(Player,Name_Of_Stat,Value) -- Sets Value onto Data Indexing(Player) and Setting(Value) to (Name_Of_Stat)
local Stats = DataStore2("Change this to what ever you want", Player)
local PlayerStatistics = Stats:GetTable(PlayerStatistics_EXAMPLE)
Stats:Update(function(PlayerStatistics)
PlayerStatistics[Name_Of_Stat] = Value
return PlayerStatistics
end)
PlayerStats_DataStore:SaveStats(Player)
end
function PlayerStats_DataStore:SetupNewData(Player)
local Stats = DataStore2("Change this to what ever you want", Player)
local PlayerStatistics = Stats:Get(PlayerStatistics_EXAMPLE)
Stats:Update(function(PlayerStatistics)
PlayerStatistics = PlayerStatistics_EXAMPLE
return PlayerStatistics
end)
print('NewData is setup for ' ..Player.Name)
Stats:Save()
end
function PlayerStats_DataStore:SetupStats(Player)
local Stats = DataStore2("Change this to what ever you want", Player)
local Data = Stats:Get(nil)
if Data then
else -- If there is no Data for player
warn('There is no Data for '.. Player.Name..' No Worries... Setting Up Data')
PlayerStats_DataStore:SetupNewData(Player)
end
end
return PlayerStats_DataStore
I see, so I can just keep adding values into that table? and also, which one do you think would be better? DS2 or PF As I want to store a large amount of items, I find it quite hard to make a datastore for each one manually. And I do come across that error quite alot " [DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 280300094]"
you got this because you made too many datastores and you don’t get an infinite amount of request to the datastore
the number of items won’t affect your datastore just be mindful of Data Stores | Roblox Creator Documentation just try not to approach the max limit of data allowed ( which had a increase a long whole ago so don’t be too worried)
Hmm, then in this case should I use profile service or datastore 2? I had to use multiple datastores for DS2 because I was saving many things