Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Cure Simulator | DataStore doesn't work and leaderstats doesn't work. Why?

I got a big problem because my DataStore doesn't work and leaderstats doesn't work and I would like some help

There's another problem too: 15:58:28.029 - Settings is not a valid member of Folder 15:58:28.029 - Stack Begin 15:58:28.030 - Script 'ServerScriptService.Script', Line 70 15:58:28.031 - Stack End

Images for where is my stuff:

Biomes folder is in workspace: https://gyazo.com/4d4e99a072148068ef3eed78e09801f5 _ Other: https://gyazo.com/76fb3959c087032beafe3e78b8014a77

ServerScriptService Script:

local Players = game:GetService("Players")

local RS = game:GetService("ReplicatedStorage")

local SS = game:GetService("ServerStorage")

local DSS = game:GetService("DataStoreService")

local RunService = game:GetService("RunService")

local ReplicatedModules = RS:WaitForChild("Modules")

local InsCreator = require(ReplicatedModules.InstanceCreator)

local DataStore = DSS:GetDataStore("Test")

function GetRandomCFrame(Part,NewPart)
	local X, Z = Part.Size.X/2,Part.Size.Z/2
	local RX,RZ = math.random(-X,X),math.random(-Z,Z)
	return Part.CFrame * CFrame.new(RX, {Part.Position.Y + NewPart.Size.Y + 0.3},RZ)
end

local function PlayerAdded(plr)
	local leaderstats = InsCreator.create("Folder", {Name = "leaderstats", Parent = plr})
	local Tubes = InsCreator.create("IntValue", {Name = "Tubes", Value = 0})
	local CURP = InsCreator.create("StringValue", {Name = "CURP", Value = 0})
	local Rebirths = InsCreator.create("StringValue", {Name = "Rebirths", Value = 0})
	
	local key = string.format("$s's data",plr.UserId)
	
	local success, err = pcall(function()
		local save = DataStore:GetAsync(key)
		if save then
			Tubes.Value = save[1]
			CURP.Value = save[2]
			Rebirths.Value = save[3]
		end
	end)
		if success then
			print(string.format("loaded $s's data",plr.Name))
	elseif err then
				warn(err)
		end
	leaderstats.Parent = plr
	Tubes.Parent = leaderstats
	CURP.Parent = leaderstats
	Rebirths.Parent = leaderstats
	
	
end

local function PlayerRemoving(plr)
	local key = string.format("$s's data",plr.UserId)
	local ls = plr.leaderstats
	local success, err = pcall(function()
		DataStore:SetAsync(key,{ls.Tubes.Value, ls.CURP.Value, ls.Rebirths.Value})
		end)
			
		if success then
			print(string.format("saved $s's data",plr.Name))
	elseif err then
				warn(err)
		end
	
end

for a, biome in pairs(workspace:WaitForChild("Biomes"):GetChildren()) do
	spawn(function()
		RunService.Heartbeat:Connect(function()
 			for i, tube in pairs(biome.Settings.Tubes:GetChildren()) do
				tube.CFrame = tube.CFrame * CFrame.fromEulerAnglesXYZ(0.02,0.02,0.02)
				
				end
			end)
		end)
			while true do
				if biome.Settings.MaxTubes.Value > #biome.Tubes:GetChildren() then
					local TubesToClone = biome.Settings.Tubes:Getchildren()
					local SelectedTubes = TubesToClone[math.random(1,#TubesToClone)]
					local NewTube = SS.Prefabs:FindFirstChild(SelectedTubes.Name):Clone()
					local Amount = math.random(math.floor(NewTube.Value.Value/1.25),math.floor(NewTube.Value.Value*1.25))
					NewTube.CFrame = GetRandomCFrame(biome.Baseplate,NewTube)
					NewTube:WaitForChild("TubeValueGUI").Value.Text = Amount
					NewTube.Parent = biome.Tubes
				end	
				
	end
end
	
	
	
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerRemoving)

Module script in replicatedstorage:

local InstanceCreator = {}

function InstanceCreator.create(class,properties)
	local newItem = {}
	newItem = Instance.new(class)
	for i, v in pairs(properties) do
		newItem[i] = v
	end
	return newItem
end

return InstanceCreator

Please help, thanks!

2 comments

0

Hello. What You have posted is too confusing to most people, drawing them away from this question. I recomend you instead Post only the main problem, or at least try to separate different parts of the script.

0

Basically the DataStore and leaderstats won't work and it makes a error too which is written above. https://gyazo.com/205619a5f5e81d05e7b66cb8be4d3c8c

1 answer

Change the name from a seperate line for your leaderstats script. I'm not sure if you can do it that way. Also, there is no Settings inside the grass folder, you would get the Biomes folder.

3 comments

0

Alright, I putted into grass the settings so https://gyazo.com/1b62a7acd6def4556ffc0d65de02a0ea but the thing is it says "CFrame is not a valid member of Folder" at line 71

0

Wait a second, are you trying to move the map?! Use a model, and set the PrimaryPart of the model to the base of the map. Then set CFrame of that.

0

I am not trying to move the map jesus

This discussion is preserved as it was. New answers, comments, and votes are closed.