I want to make a system but in order to do so it needs to access soem contents in a table from a module that I have published. Basically so this script works in any game when it dosent have the module but it dosen’t need it because of it accessing the published module.
The module will be on toolbox but no one can buy it.
You can do this by publishing a ModuleScript to the toolbox and naming it Main Module
Then you use require(ModelId)
to access it:
-- Example
local data = require(29310480123)
It has to be publicly available in order to do that
Alr, but how would i access the data of it, it is set out in a table.
You would access it to same way as a normal table
-- Example
local data = require(2021903239)
local copy = table.clone(data) -- copies the table data
If you want to; It only refers to the animation data from the animation editor. If your Module requires the animation data, then keep it off
alr. What dsoe table.clone do?
It gose off if a suer owns a licnece (a gamepass) then it checks the product version
I understand that it coppys the data but then how do i access liek a value inside of the module
It returns the table in the module, just use the table like how you normally would
local data = require(201980213)
-- 'data' is the table
--[[
It's the same as:
local data = {}
--]]
Im just confused. Sure I have 4 minths experience but I am still new.
I jsut want to access the table data
local VersionData = require(16230681000)
local Copy = table.clone(VersionData)
local ProductVersionValue = game.Workspace.ProductVersions
if ProductVersionValue.Value ~= VersionData["Test Asset 1"]["Product Version"].value then
end
Alright so, I don’t think this is right but something like this is what I am after to access. Then I want it to kick the player with a customisable reason if the ProductVersionValue.Value dose not equal the same as the value in the VersionData module scirpt.
You don’t have to do this; it was just for the example
The code you provided (assuming that VersionData
is entirely a table) is correct. Just for clarification though, how is your table structured?
The data module, should look like this.
local Data = {
['YourGamepass']={
name='test',
id=000000
},
}
return Data
Then in another script, you’ll do
local Data = require(theDataModule)
print(Data['YourGamePass'] -- print: name = 'test', id = 0000000
My table is structured like this:
local ProductVersions = {
["Test Asset 1"] = {
["Name"] = "Test Asset 1",
["Product Version"] = 2
}
}
return ProductVersions
I jsut gave it a different name in the script for readability and dsoen’t matter due to it getting it form the ID of th emodle that was referenced at the beginning of the main script.
That’s the same structure as mine. So you require ProductVersions, and then you can that
local data = require(ProductVersionsModule)
print(data["Test Asset 1"] -- prints: "Test Asset 1", 2
Do i need to pritn data I jsut need it to acess data and kick the player if the ProductVersionValue.Value ~= VersionData[“Test Asset 1”][“Product Version”].value
No, you don’t need to print it. I just put that there to illustrate how it works.
Your code should look like this:
local VersionData = require(16230681000)
local ProductVersionValue = game.Workspace.ProductVersions
if ProductVersionValue.Value ~= VersionData["Test Asset 1"]["Product Version"] then
-- "Product Version" is already a number, so you don't need to include '.value'
print("Outdated Asset") -- This lets you know the asset is outdated
-- Since this is being ran on the server, every player in the game should be kicked.
-- This can't run on the client.
for _, player in game:GetService("Players"):GetPlayers() do
player:Kick("Outdated")
end
end
So bascially what ever product it is if it dosent equal the value then it kicks them with the reason and tells the user what product it is.
I have somethign liek this below:
local VersionData = require(16230681000)
local Copy = table.clone(VersionData)
local ProductVersionValue = game.Workspace.ProductVersions
local Player = game.Players.ChildAdded:Connect()
local KickReason = "PRODVERSION | The product"
if ProductVersionValue.Value ~= VersionData["Test Asset 1"]["Product Version"].value then
Player:kick()
end
If it is easier jsut make different kickreasons