[edited og title bc it sounded like a different issue)
trying to set a table value [“Part0”] to a weld.Part0
it works fine, except, when i change the value in playing of said weld and run the code the table value doesnt become the new one, it stays the value it was assigned when the weld was created with Instance.new(“Weld”)
i have tried searching for this issue around google with no results giving even the same issue, making me think this is a really simple mistake im making lol
my code
function that is suppose to grab and set the [“Part0”] to the weld.Part0
local function InitProps(objects)
local tableToSave = {}
for _, obj in pairs(objects) do
local class = obj.ClassName
print("obj.classname is "..obj.ClassName)
print("obj.name is "..obj.Name)
local t = tableToSave[class]
if not(t) then
tableToSave[class] = {}
t = tableToSave[class]
end
local add = {
}
for _, prop in pairs(Properties[obj.ClassName]) do
add[prop] = Serialize(obj[prop])
if prop == "Name" then add["Name"] = obj.Name
end
local UserSetName = obj:GetAttribute("UserSetName")
add["UserSetName"] = UserSetName
if prop == "Part0" then
if obj.Part0 == nil then
add["Part0"] = "nil"
else
add["Part0"] = obj.Part0:GetFullName()
print(add["Part0"])
end
end
if prop == "Part1" then
if obj.Part0 == nil then
add["Part1"] = "nil"
else
add["Part1"] = obj.Part1:GetFullName()
print(add["Part1"])
end
end
--also worth noting here if i remove these last 4 ifs (if prop/if obj.)
--the parts do not show up in my table
end
local children = obj:GetChildren()
if #children > 0 then
add["Children"] = InitProps(children)
end
table.insert(t, add)
end
print(tableToSave)
return tableToSave
end
module that spawns the weld
local module = {}
local HttpService = game:GetService("HttpService")
local playerService = game:GetService("Players")
function module.CreateWeld(position, p, part0, part1)
local parent = p or workspace:FindFirstChild(playerService.name)
local inheritPart0 = part0
local inheritPart1 = part1
local weld = Instance.new("Weld")
weld.Name = HttpService:GenerateGUID(false) -- name for id/instancing
weld.Part0 = inheritPart0 or nil
weld.Part1 = inheritPart1 or nil
weld.Parent = parent
weld:setAttribute("UserSetName", "weld") --name shown to users
return weld
end
return module
changed value in studio
result after changing value in studio and running InititProps(objects) (this is the printed tableToSave)