Tables Help and Support

Hey there,

i’m new to tables and still dont really understand them but here we are. i just made a table for creating a player plot. how would i make a local script for when a button is pressed it would display data such as farm name and creation date?

-- // SERVICES

local players = game:GetService("Players")
local rs = game.ReplicatedStorage

-- // VARS

local savePrefix = "plotData-"
local plotFramework = rs.PlotFramework
local creationEvents = plotFramework.creatingEvents
local createPlot = creationEvents.createPlot

-- // CODE

createPlot.OnServerEvent:Connect(function(player, name)

	local plotData = {
		playerName = player.Name,
		farmName = name,
		creationTime = DateTime.now():FormatLocalTime("LT","en-us").." "..DateTime.now():FormatLocalTime("LL","en-us"),
		plotSize = 25,
		Objects = {}
	}
	
	local plot = plotFramework.plotBase.basePlot
	local clone = plot:Clone()
	
	clone.Size = Vector3.new(plotData["plotSize"],.25,plotData["plotSize"])
	clone.Name = player.Name.."-plot"
	clone.Parent = game.Workspace.playerPlots
	
	print("Plot Data:")
	for key, value in pairs(plotData) do
		print(key, value)
	end
end)

Honestly, you already got a lot of hard work done for yourself.

If you’re trying to make this current server script communicate with a local script, then utilize :FireClient() with that same remove event. Something like createPlot:FireClient(player, plotData).

You can send the data obtained through the server to the client that way.

Once you’re that far, displaying the data such as farm name and creation date should be a breeze.

-- inside your local script.
	
	
local farm_name = nil -- wherever it is
local creation_data = nil -- wherever that is. 	
	
createPlot.OnClientEvent:Connect(function(plotData)
	farm_name.Text = plotData.farmName
	creation_data = plotData.creationTime
end)
1 Like

ah yes! thank you so much, now im trying to figure out how to make it list all the players previous saves. i dont even know where to start.

If you’re dealing with saves, and you’re a novice scripter. I highly advise you looking into ProfileService and using that. It’ll create a versatile DataManager for yourself that you can use in all your games. Inside that DataManager you’d deal with all the prior saves, and honestly man that’s not something I can explain in one thread haha. Heres some helpful links though.

ProfileService Documentation

Setting up - ProfileService

The Model

https://create.roblox.com/store/asset/5331689994?externalSource=www

Tutorial

https://www.youtube.com/watch?v=xZqxMjO62fk&t=784s

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.