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

Simulator DataStore doesn't work and error occours, Why?

Hello, I've been working on my simulator for a while and I got this error:

14:59:05.767 - ServerScriptService.Script:95: Expected ')' (to close '(' at line 68), got 'Players'

The script is inside ServerScriptService, and the Modules folder and InstanceCreator is inside ReplicatedStorage. The Prefabs are not spawning and my leaderstats doesn't save why? Please help

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("Bioms"):GetChildren()) do
	spawn(function()
		RunService.Heartbeat:Connect(function()
			for i, tube in pairs(biome.Tubes:GetChildren()) do
				tube.CFrame = tube.CFrame * CFrame.fromEulerAnglesXYZ(0.02,0.02,0.02)
				
				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)

I would like lots of helps thanks!

1 answer

You're missing a ')' at line 92 Players.PlayerAdded:Connect(PlayerAdded)

19 comments

0

But where in that line 92?

0

Where you put the "Players.PlayerAdded:Connect(PlayerAdded" at the end of the script you missed a ')' at the end of the event, put a ')' there and it should solve it.

0

He gave the correct version of ur error

0

And I putted that ')' in the end and the "Players" have red lined means it has some error stuff

0

15:18:15.805 - ServerScriptService.Script:92: Expected ')' (to close '(' at line 68), got 'Players' - It still doing this

0

Oh, you missed an ')' aswell at line 68 where you have "spawn(function()" supposed to be "spawn(function())" I believe. try that and see if it works.

0

It makes it red lined

0

Yeah, I was wrong. I'll keep looking at the script.

0

You're missing an "end)" at line 74, add an "end)" there and see if it works.

0

Alright imma check that out

0

It's good but the thing is this: 15:32:52.911 - Tubes is not a valid member of Folder 15:32:52.912 - Stack Begin 15:32:52.912 - Script 'ServerScriptService.Script', Line 70 15:32:52.913 - Stack End

0

Well, that's a separate issue, did you miss-name "Biomes" with "Bioms" at line 67? If not then the location is wrong.

0

I fixed the "Biomes" It was "Bioms" and made it this line to : for a, biome in pairs(workspace:WaitForChild("Biomes"):GetChildren()) do

0

But It still doesn't work, Can I friend you on discord? because I may have to send you screenshots, If yes please send me your discord.

0

You can download Gyazo to take screenshots and it'll make a link for you to send it to me through here.

0

Well, looking at the first screenshot, Tubes isn't in Biomes, it's in Settings, wouldn't you need to do Biomes.Settings.Tubes:GetChildren() on line 70? If that doesn't help then I'd suggest creating another Question with this issue.

0

It now says Settings is not a valid member of folder

0

I'd suggest you create another Question with this issue.

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