i am making a 3d platformer game in roblox and wanted to make a portal that only opens after you collect 5 collectibles
i dont know how to script at all so i posted on the devforum asking how i would be able to do this but no one knew
then i had an idea to make it so that theres a button under the collectible and when you touch it it would open a door and there are 5 doors infront of the portal and it worked
now i want to know how would i use datastores to store that so when a player came back the buttons that they pressed would still be pressed and the door would still be open
if this isnt possible then how would i be able to make it so that the buttons would add something to the leaderstat and once you have 5 then the portal would open?
You can probably just track how many collectibles the player has, then open the portal. Whatever collect event/function you use can also update what was collected and then checks how many have been collected in total.
--[[This here assumes that you are using Touched and that specific collectibles
aren't being tracked.]]
local Player = game.Players.LocalPlayer
local CollectAmount = 0
function OpenPortal()
--However you open the portal
end
function Collect(TouchedPart) --Whatever collect system you use, whether touched, clicked, or keybind
if TouchedPart == "Collectible" then
CollectAmount = CollectAmount + 1
if CollectAmount == 5 then
OpenPortal()
end
end
end
Player.Character.HumanoidRootPart.Touched:Connect(Collect)
Don’t know how things are set up in your game, but I’d do something like this.
Regarding datastore and buttons (I don’t really use datastore), you can probably set up a remoteevent that sends what button was pressed to the server. The server just stores that somewhere, then when the player leaves all the pressed buttons are saved in a table. When the player returns then the server can load up the buttons and press them serverside or tell the client to press them (however pressing is done).