Ive been trying to make a game where the parts i put into workspace are transfered into all servers live.
But for some reason the parts are only being created in studio
and they also duplicate themselves and i don’t know how to fix it.
these are my scripts :
Script in workspace
local MessageService = game:GetService("MessagingService")
function TableToVector3Table(table)
local result = {}
for key, value in pairs(table) do
if type(value) == "table" and #value == 3 then
result[key] = Vector3.new(value[1], value[2], value[3])
else
result[key] = value
end
end
return result
end
MessageService:SubscribeAsync("CreateBlock",function(Income)
local BlockTest = game:GetService("HttpService"):JSONDecode(Income.Data)
print(BlockTest)
local Block = TableToVector3Table(BlockTest)
print(Block)
if type(Block) == type({}) then
print("Started creating part")
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Position = Block.Position
Part.Size = Block.Size
Instance.new("CustomEvent",Part).Name = "LiveMade"
Part.Rotation = Block.Rotation
Part.Anchored = Block.Anchored
Part.CanCollide = Block.CanCollide
Part.Transparency = Block.Transparency
warn("Done")
else
error("Expected 'Table' got '" .. type(Block) .. "'.")
end
end)
ModuleScript in ServerScriptService that is being used by the studio client
local module = {}
function Vector3TableToTable(vector3Table)
local result = {}
for key, value in pairs(vector3Table) do
if typeof(value) == "Vector3" then
result[key] = {value.X, value.Y, value.Z}
else
result[key] = value
end
end
return result
end
function module:Start()
print("Started")
local MessageService = game:GetService("MessagingService")
workspace.DescendantAdded:Connect(function(Block)
task.wait(0.1)
if not Block:FindFirstChild("LiveMade") then
if Block:IsA("Part") then
local TableBlock = {}
TableBlock.Parent = Block.Parent
TableBlock.Position = Block.Position
TableBlock.Size = Block.Size
TableBlock.CanCollide = Block.CanCollide
TableBlock.Transparency = Block.Transparency
TableBlock.Anchored = Block.Anchored
TableBlock.Rotation = Block.Rotation
local convertedTable = Vector3TableToTable(TableBlock)
local jsonEncoded = game:GetService("HttpService"):JSONEncode(convertedTable)
MessageService:PublishAsync("CreateBlock",jsonEncoded)
end
end
end)
end
return module
Note : I have studio API Services enabled so its not that.