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

[SOLVED]Cannot load my plot? What is happening

Hello! I recently started to redo my placement system, i have come into a few problems here and there solving them quickly, but this one i'm stumped on. Anybody know why this is happening?

Screenshots

Rep storage

Plots

My GUI

(VERY LONG SCRIPTS INCOMING)

Server Scripts(I have several)

All script is not having problems except BaseHandler(i will include all of them just incase they don't work)

If you need the placement moudule, comment. k thanks bye

Placement module: pastebin(because its so long)

BaseHandler(~100 lines)

local players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local CashStore = DataStoreService:GetDataStore("BaseSave")

local plot

local function GetPlot(player)
	for i, plt in pairs(workspace.Plots:GetChildren()) do
		if plt then
			if plt.Plot.Owner.Value == player then
				plot = workspace.Plots:FindFirstChild(plt.Name)
				
				
				break
			end
		end
	end
end


players.PlayerAdded:Connect(function(plr)

	local key = "plr-"..plr.UserId
	
	local savedata
	
	local success, err = pcall(function()
		savedata = CashStore:GetAsync(key)
		
	end)

	if success then
		for i, data in pairs(savedata) do
			if data then
				local savemodel = game.ReplicatedStorage.Items:FindFirstChild(data.Name)
				
				if savemodel then
					savemodel.PrimaryPart.Transparency = 1
					
					savemodel:SetPrimaryPartCFrame(CFrame.new(data.CFS.X, data.CFS.Y, data.CFS.Z) * CFrame.Angles(0, math.rad(data.CFS.R, 0)))
					
				end
				
				savemodel.Parent = plot.PlacedObjects
			end
		end
	end
	
	if not success then
		error("Failled to read data: "..tostring(err).." Check line 20 in DataHandler and below to fix problem, if you are a non-developer. Message the developer(s) with a screenshot as SOON AS POSSIBLE")
		return
	end
	

end)

local function save(plr)
	wait(1)
	
	GetPlot(plr)
	
	local key = "plr-"..plr.UserId
	
	local save = {}
	
	for i, object in pairs(plot.PlacedObjects:GetChildren()) do
		if object then
			table.insert(save, {
				["Name"] = object.Name;
				
				["CFS"] = {
					["X"] = object.PrimaryPart.CFrame.X;
					["Z"] = object.PrimaryPart.CFrame.Z;
					["Y"] = object.PrimaryPart.CFrame.Y;
					
					["R"] = object.PrimaryPart.Orientation.Y;
				};
				


			})
		end
	end
	
	local success, err = pcall(function()
		CashStore:SetAsync(key, save)
	end)
	
	if not success then
		error("(CRITICAL) Failled to over-write data: "..tostring(err).." Check line 53 in BaseHandler and below to fix problem, if you are a non-developer. Message the developer(s) with a screenshot as SOON AS POSSIBLE")
		return
	end
end

game.ReplicatedStorage.Remotes.Save.OnServerEvent:Connect(save)

PlacementServer(17 lines)

game.ReplicatedStorage.Remotes.PlaceObject.OnServerEvent:Connect(function(plr, mdlNm, X, Y, Z, R, location)
	local model = game.ReplicatedStorage.Items:FindFirstChild(mdlNm):Clone()
	
	if plr.leaderstats.Cash.Value >=  model.Price.Value then
		model:SetPrimaryPartCFrame(CFrame.new(X, Y, Z) * CFrame.Angles(0, math.rad(R), 0))
		model.PrimaryPart.CanCollide = false
		model.PrimaryPart.Transparency = 1
		
		model.Parent = location
		plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - model.Price.Value
		
	else
		model:Destroy()
		model = nil
		return
	end
end)

DataHandler

local players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local CashStore = DataStoreService:GetDataStore("CashData1")


players.PlayerAdded:Connect(function(plr)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr
	
	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Value = 1000
	cash.Parent = stats
	
	local key = "plr-"..plr.UserId
	
	local savedata
	
	local success, err = pcall(function()
		savedata = CashStore:GetAsync(key)
		
	end)
	
	if not success then
		warn("Failled to read data: "..tostring(err).." Check line 20 in DataHandler and below to fix problem, if you are a non-developer. Message the developer(s) with a screenshot as SOON AS POSSIBLE")
		return
	end
	
	if savedata then
		cash.Value = savedata.Cash
	else
		local key = "plr-"..plr.UserId
	
		local save = {
			["Cash"] = plr.leaderstats.Cash.Value	
		}
	
		local success, err = pcall(function()
			CashStore:SetAsync(key, save)
		end)
	end
end)

players.PlayerRemoving:Connect(function(plr)
	local key = "plr-"..plr.UserId
	
	local save = {
		["Cash"] = plr.leaderstats.Cash.Value	
	}
	
	local success, err = pcall(function()
		CashStore:SetAsync(key, save)
	end)
	
	
	if not success then
		warn("Failled to over-write data: "..tostring(err).." Check line 20 in DataHandler and below to fix problem, if you are a non-developer. Message the developer(s) with a screenshot as SOON AS POSSIBLE")
		return
	end
end)

PlotHandler

local players = game:GetService("Players")
local plots = workspace.Plots

local function FindPlot(plr)
	local plotchirden = plots:GetChildren()
	
	for i,plt in pairs(plotchirden) do
		if plt then
			if plt.Plot.Owner.Value ~= nil then
				print("Plot owner is: " ..plt.Plot.Owner.Value.Name)
			else
				local pltNm = plt.Name
				
				game.ReplicatedStorage.Remotes.ClientPlot:FireClient(plr, pltNm)
				
				plt.Plot.Owner.Value = plr
				
				break
			end
		end
	end
end

players.PlayerAdded:Connect(FindPlot)

LOCAL SCRIPTS

PlacementClient

local placementMoudule = require(game.ReplicatedStorage.Modules.PlacementModule)
local plot
local plauer = game.Players.LocalPlayer
local mouse = plauer:GetMouse()

game.ReplicatedStorage.Remotes.ClientPlot.OnClientEvent:Connect(function(pltNm)
	plot = workspace.Plots:FindFirstChild(pltNm)
end)


for i, v in pairs(script.Parent.MainFrame:GetChildren()) do
	v.MouseButton1Click:Connect(function()
		placementMoudule:StartPlacement(game.ReplicatedStorage.Items, v.Name, plot.Plot, plot.PlacedObjects)
	end)
end

mouse.Button1Down:Connect(function()
	placementMoudule:PlaceModel(plot.PlacedObjects, game.ReplicatedStorage.Remotes.PlaceObject)
end)



GUICLIENTSAVE

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Remotes.Save:FireServer()
end)

AUTOCLIENTSAVE

local autosavewait = 20

while true do
	wait(autosavewait)
	
	game.ReplicatedStorage.Remotes.Save:FireServer()
end

3 comments

1

What script/line is the error on?

0

i fixed it, really fast somehow my table was causing some of the problems. accidental fix 

0

I just had to edit the placement module(giant script btw) a bit, and some of the basehandler

1 answer

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