How to Make Server-Synced Daily Shops

That’s not related to the question.

Hope this explains it to you :).

2 Likes

Okay I’m back after a few days of making my own daily synced shop. This is such a goldmine of a resource, thank you for creating it. Without it I probably would’ve tried to use DataStoreService or some other horrible technique.

bf78ed599cefa01b9a6712f59716cf53

Super cool (as well as synced & random) results. My store is a little bit more complex than the tutorial, but I managed to figure it all out. Random.New(seed) is by far my most favorite thing about Roblox, even though it’s quite basic. :smiling_face_with_three_hearts:

1 Like

Hey there! Going to post here again because I have a question. The tutorial is super good, so good that I am using for my daily objectives update. My only issue right now is trying to figure out how to reset data without doing it every time the script loads.

When you join the game and this starts up,

while true do
	local day = math.floor((syncedtime.time() - offset) / (60 * 60 * 24))
	local t = (math.floor(syncedtime.time())) - offset
	local daypass = t % 86400
	local timeleft = 86400 - daypass
	local timeleftstring = toHMS(timeleft)
	
	local sentence = ("Time till tasks reset: " .. timeleftstring)
	
	if day ~= currentDay then
		currentDay = day
		currentBasicTasks = getAvailableItems(day, 3)
		print("Today's Basic Tasks: " .. table.concat(currentBasicTasks, ", "))
		currentPremiumTasks = getAvailablePremiumItems(day, 3)
		print("Today's Premium Tasks: " .. table.concat(currentPremiumTasks, ", "))
		game.ServerStorage.NameChangeEvent:Fire()
	end
	updateTimerEvent:FireAllClients(sentence)
	wait(1)
end

every time that if statement executes, because the day is never = to the currentDay when the script starts, even when technically it is. How can I fire this statement

game.ServerStorage.NameChangeEvent:Fire()

but only when it needs to happen(when 24 hours are up) instead of every time the script loads
If I am not explaining myself well please tell me, I would like to figure this out!

Really nice tutorial! I mainly used it for a reference to see if my approach matched up with how other people tackle the problem.

Thank you this helped me a lot and save me a lot of time :+1:

umm you can make a remote event which every time the shop resets it fires all clients to refresh the shop

Hey that is great but i have a question is that for single server or for globally? Like the stuffs in shop has same on all servers

It’s the same on all servers. Random.new(day) makes sure that all servers will get the same RNG, meaning everything will generate the same on every server.

This actually helped alot Most of the time’s these things are really difficult to make thanks so much!

How would I go about making a GUI for this?

More specifically, when the script generates the items, how would I go about getting each individual item it chooses, finding a matching tool in a folder with the same name as the chosen item, to then use its values for a shop GUI?

Edit: Figured it out

On a different note, how would you want it so the script updates without having to join a new server?

Which would then in turn, update the GUI

Edit: Found out how to

So, I don’t want the item to be picked randomly, I want a certain item to always be on the shop on one day, then I want another certain item to be on the shop on the second day. How would i Make that?
Ex: day 1:orange - day 2:apple - day 3: grape - day 4: orange - day 5: apple…(and it keeps repeating).

Then just do days mod amount of items and the remainder is the item you pick

This system is awesome! I have a question though. How would I apply this to a sort of category system? I’m making a game that revolves around 4 weapon types. In the shop I want there to be 4 slots, in those slots will be skins for each weapon type. So slot 1 = weapontype1, slot 2 = weapontype2, etc. And in these slots it does the same exact system of rotating daily however only skins for that weapon type will appear in their respective slot. For example only skins for weapontype1 will appear in slot one. I think I may have an idea on how to do this, pretty much just using the normal system but making it separate for every weapon type. Is there a better way to do this by chance?

I love this system! However I have a question. I’m making a module script that has a dictionary of every cosmetic in the game. This dictionary stores the info such as name, model, rarity, price, and imageid. In the tutorial you say make tables for all the items of certain rarities. Would it be possible to just use the module script dictionary instead since it stores the rarity of every cosmetic within it? If so how would I properly implement this way of rarity storing into the function?

This is exactly what I was looking for! My game has something like this too and I’ve been absolutely stumped on how to do this

I got to say, this is an absolutely fantastic tutorial. Great job!

how do i change the item amount of the daily shop? i tried to change to amount but it keeps saying respinning

currentShopItems = getAvailableItems(day, 7)

Change the second number to however many items you want.