This is the starter place
And this is the subplace
In the subplace there is a star
There is also a script that creates a value within the player called “StarFound”
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local StarFound = Instance.new("BoolValue")
StarFound.Name = "StarFound"
StarFound.Parent = player
end
Players.PlayerAdded:Connect(onPlayerAdded)
There is a script in the star that sets this value to true when you collect it
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
Player.StarFound.Value = true
print("The red star has been collected")
Player.Character:MoveTo(game.Workspace.SpawnLocation.Position)
end)
There is also a return pad
It teleports you back to the starter place with the data that shows that you have the red star collected
This is the teleport script
local TS = game:GetService("TeleportService")
local ID = 10521274055
local Utils = require(game.ServerScriptService.Utils)
local Pad = script.Parent
local function onTouch(otherPart)
local Player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if Player then
Utils:SaveData(Player)
TS:Teleport(ID, Player)
end
end
Pad.Touched:Connect(onTouch)
And this is the Utils script
local Utils = {}
local DSS = game:GetService("DataStoreService")
local RedStarDataStore = DSS:GetDataStore("RedStarDataStore")
function Utils:SaveData(Player)
local Data = {}
Data.FoundRedStar = Player.StarFound.Value
RedStarDataStore:SetAsync(Player.UserId, Data)
end
function Utils:InitData(Player)
local Data = RedStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.RedStar.Value = true
end
end
return Utils
When you get back to the starter place there is a separate utils script that loads the saved data
local Utils = {}
local DSS = game:GetService("DataStoreService")
local RedStarDataStore = DSS:GetDataStore("RedStarDataStore")
local BlueStarDataStore = DSS:GetDataStore("BlueStarDataStore")
local OrangeStarDataStore = DSS:GetDataStore("OrangeStarDataStore")
local GreenStarDataStore = DSS:GetDataStore("GreenStarDataStore")
local PurpleStarDataStore = DSS:GetDataStore("PurpleStarDataStore")
function Utils:ititRedData(Player)
local Data = RedStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.RedStar.Value = Data.FoundRedStar
print("The red star has been collected and this works after literally 2 GODDAMN MONTHS")
end
end
function Utils:initBlueData(Player)
local Data = BlueStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.BlueStar.Value = Data.FoundBlueStar
print("The blue star has been found lolololololololo")
end
end
function Utils:ititOrangeData(Player)
local Data = OrangeStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.OrangeStar.Value = Data.FoundOrangeStar
print("The orange star has been collected and it should show up on the gui and if it does i am going to jump for joy so hard actually i cant cos ill make too much noise but i literally went 3 STRAIGHT HOURS TRYNA FIGURE OUT WHAT TO DO SO IT BETTER WORK")
end
end
function Utils:initGreenData(Player)
local Data = GreenStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.GreenStar.Value = Data.FoundGreenStar
print("The green star has been collected and I know this works cos it works for every other star so ye")
end
end
function Utils:initPurpleData(Player)
local Data = PurpleStarDataStore:GetAsync(Player.UserId)
if Data then
Player.CollectedStars.PurpleStar.Value = Data.FoundPurpleStar
end
end
return Utils
Ignore all the other colors they’re just other levels
There is also a script that runs the initData function
local Utils = require(game.ServerScriptService.Utils)
game.Players.PlayerAdded:Connect(function(Player)
Utils:ititRedData(Player)
Utils:initBlueData(Player)
Utils:ititOrangeData(Player)
Utils:initGreenData(Player)
Utils:initPurpleData(Player)
end)
This script seemed to be working 2 weeks ago but for some reason it just stopped working. I didn’t edit ANYTHING or change ANY values but it just doesn’t save the data anymore.
PLEASE HELP!!!