Folder name isn't changing

I’m making a speedrun game, I store all of your best times in an int value inside of a folder in the player. I’ve just added new stages so I had to create 4 more folders with int values inside of it. Now, I’m getting this error message whenever I run the game Stage4 is not a valid member of Folder “Players.Coder_Tom.Times”, even though there is this part in the script: (Full script below)

	local Stage4 ="Folder", Times)
	Stage4.Name = "Stage4"
	local Stage4BestTime ="IntValue", Stage4)
	Stage4BestTime.Name = "BestTime"
	Stage4BestTime.Value = 0

Full script:
local mps = game:GetService("MarketplaceService")
local dss = game:GetService("DataStoreService")
local dataStore = dss:GetDataStore("SaveAllPlayerData")

	local leaderstats ="Folder", player)
	leaderstats.Name = "leaderstats"
	local Times ="Folder", player)
	Times.Name = "Times"
	local Coins ="IntValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Value = 0
	local Level ="IntValue", leaderstats)
	Level.Name = "Level"
	Level.Value = 1
	Creating the stage values.
	local Stage1 ="Folder", Times)
	Stage1.Name = "Stage1"
	local Stage1BestTime ="IntValue", Stage1)
	Stage1BestTime.Value = 0
	Stage1BestTime.Name = "BestTime"
	local Stage2 ="Folder", Times)
	Stage2.Name = "Stage2"

	local Stage2BestTime ="IntValue", Stage2)
	Stage2BestTime.Value = 0
	Stage2BestTime.Name = "BestTime"
	local Stage3 ="Folder", Times)
	Stage3.Name = "Stage3"

	local Stage3BestTime ="IntValue", Stage3)
	Stage3BestTime.Value = 0
	Stage3BestTime.Name = "BestTime"
	local Stage4 ="Folder", Times)
	Stage4.Name = "Stage4"
	local Stage4BestTime ="IntValue", Stage4)
	Stage4BestTime.Name = "BestTime"
	Stage4BestTime.Value = 0
	local Stage5 ="Folder", Times)
	Stage5.Name = "Stage5"

	local Stage5BestTime ="IntValue", Stage5)
	Stage5BestTime.Value = 0
	Stage5BestTime.Name = "BestTime"

	local Stage6 ="Folder", Times)
	Stage6.Name = "Stage6"

	local Stage6BestTime ="IntValue", Stage6)
	Stage6BestTime.Value = 0
	Stage6BestTime.Name = "BestTime"

	local Stage7 ="Folder", Times)
	Stage7.Name = "Stage7"

	local Stage7BestTime ="IntValue", Stage7)
	Stage7BestTime.Value = 0
	Stage7BestTime.Name = "BestTime"

	local StageHardmode ="Folder", Times)
	Stage4.Name = "StageHardmode"

	local StageHardmodeBestTime ="IntValue", StageHardmode)
	StageHardmodeBestTime.Value = 0
	StageHardmodeBestTime.Name = "BestTime"
	--Creating the trail inventory items.
	local Trails ="Folder", player)
	Trails.Name = "Trails"
	local GreyTrail ="IntValue", Trails)
	GreyTrail.Name = "GreyTrail"
	GreyTrail.Value = 0
	local RedTrail ="IntValue", Trails)
	RedTrail.Name = "RedTrail"
	RedTrail.Value = 0
	local RainbowTrail ="IntValue", Trails)
	RainbowTrail.Name = "RainbowTrail"
	RainbowTrail.Value = 0
	--Creating quest values.
	local Quests ="Folder", player)
	Quests.Name = "Quests"
	local Speedrun ="BoolValue", Quests)
	Speedrun.Name = "Speedrun"
	Speedrun.Value = false
	local BackpackItems ="Folder", player)
	BackpackItems.Name = "BackpackItems"
	local SpeedCoil ="IntValue", BackpackItems)
	SpeedCoil.Name = "SpeedCoil"
	SpeedCoil.Value = 0
	local stat = dataStore:GetAsync(player.UserId)
	if stat ~= nil then
		print("Player_"..player.UserId.." has data, successfully loaded data.")
		Coins.Value = stat[1]
		Level.Value = stat[2]
		Stage1BestTime.Value = stat[3]
		Stage2BestTime.Value = stat[4]
		Stage3BestTime.Value = stat[5]
		Stage4BestTime.Value = stat[6]
		RainbowTrail.Value = stat[7]
		RedTrail.Value = stat[8]
		GreyTrail.Value = stat[9]
		Speedrun.Value = stat[10]
		SpeedCoil.Value = stat[11]
		Stage5BestTime.Value = stat[12]
		Stage6BestTime.Value = stat[13]
		Stage7BestTime.Value = stat[14]
		StageHardmodeBestTime.Value = stat[15]
		print("Player_"..player.UserId.." does not have any data.")
		Coins.Value = 0
		Level.Value = 1
		Stage1BestTime.Value = 0
		Stage2BestTime.Value = 0
		Stage3BestTime.Value = 0
		Stage4BestTime.Value = 0
		RainbowTrail.Value = 0
		RedTrail.Value = 0
		GreyTrail.Value = 0
		SpeedCoil.Value = 0
		Stage5BestTime.Value = 0
		Stage6BestTime.Value = 0
		Stage7BestTime.Value = 0
		StageHardmodeBestTime.Value = 0

	local save = {}
	table.insert(save, player.leaderstats.Coins.Value)
	table.insert(save, player.leaderstats.Level.Value)
	table.insert(save, player.Times.Stage1.BestTime.Value)
	table.insert(save, player.Times.Stage2.BestTime.Value)
	table.insert(save, player.Times.Stage3.BestTime.Value) 
	table.insert(save, player.Times.Stage4.BestTime.Value)
	table.insert(save, player.Trails.RainbowTrail.Value)
	table.insert(save, player.Trails.RedTrail.Value)
	table.insert(save, player.Trails.GreyTrail.Value)
	table.insert(save, player.Quests.Speedrun.Value)
	table.insert(save, player.BackpackItems.SpeedCoil.Value)
	table.insert(save, player.Times.Stage5.BestTime.Value)
	table.insert(save, player.Times.Stage6.BestTime.Value)
	table.insert(save, player.Times.Stage7.BestTime.Value)
	table.insert(save, player.Times.StageHardmode.BestTime.Value)
	local success, errormessage = pcall(function()
		dataStore:SetAsync(player.UserId, save)
	if success then
		print("Saved: "..player.Name.."_"..player.UserId)

Also, whenever I look inside of the player model when playing, the Stage 4 folder is called Folder for some reason, so it’s not changing its name, still has the int value. Any help would be much appreciated :slight_smile:


found the impostor:

local StageHardmode ="Folder", Times)
	Stage4.Name = "StageHardmode" <<<<<<<<<<<<< Stage4.Name, 

Correct was StageHardmode.Name
1 Like

Thank you so much, I’ve been trying to fix rthis for hours lmao

i know because that happened to me before xD

1 Like