let’s say i have a player do a task, once they finish that task, what should I use to check if they did that task from other scripts?
For example: if i had 5 things the player needed to do to open a door to proceed in the game, where and how would I store the 5 checkpoints to see if they did them?
There are several ways you can store and check checkpoints in a game to track player progress. Here are a few common approaches:
Player Data Storage: Store the player’s progress and checkpoints on a server or in a database. This allows the player’s progress to be persistent across different play sessions and devices. You can use a database service like Firebase or create your own server-side solution. Each time the player completes a task, you update their progress in the database. Other scripts can then retrieve the player’s progress and check if the required tasks have been completed.
Data Store Service: Use a data store service provided by the game development platform or engine you are using. For example, Roblox provides a DataStore service that allows you to save and retrieve player data. You can use this service to store the player’s progress and checkpoints. Other scripts can access the data store to check the completion status of tasks.
Game Manager/Manager Script: Create a central script that acts as a manager or controller for the game’s progress. This script can keep track of the player’s progress and store the completion status of tasks. Other scripts can communicate with the manager script to check if the required tasks have been completed.
Local Storage: If the game doesn’t require persistent progress across play sessions or devices, you can store the player’s progress locally on their device. Use a data structure such as a table or JSON file to store the completion status of tasks. Other scripts can access this data to check the completion status.
The best approach depends on your game’s requirements and platform. If your game is multiplayer or requires persistent progress, using a server or data store service is recommended.
Maybe use a boolvalue to see if the task has been done. You can reset it and set it to done every time it’s done and given. Then, if it isn’t accessible easily, maybe make a copy of it in an attribute or what not and then check the value with the script. For example
local TaskDone = script.Parent.Parent.TaskDone.Value -- Just an example path
if TaskDone == true then
print("Completed")
else
print("Not Completed")
end
or
local Task1Done = script.Parent.Parent.Task1Done.Value -- Just an example path
local Task2Done = script.Parent.Parent.Task2Done.Value -- Another example path
if Task1Done== true then
print("Completed")
if Task2Done == true then
print("Completed")
end
else
print("Not Completed")
end
I know that code example is spaghetti code but you get what I mean, right?