【发布时间】:2021-11-28 15:09:44
【问题描述】:
我在搜索引擎中寻找此问题的解决方案,但找不到。
虽然有一个几乎相同,即“无效参数 #2(预期字符串,已获取实例)”,但我尝试寻找反向修复它的方法,但它使用 tostring(),我的问题是关于最新功能:Instance Attributes,它不支持实例作为值,我唯一能做的就是将其转换为字符串,现在问题是关于使用 Adornee/Instance 或其他东西的 Part.Parent我不知道解决方法
local LocalPlayer = Players.LocalPlayer;
local Mouse = LocalPlayer:GetMouse();
local function Part_Hide()
if (Toggle_MouseHover == true and Mouse.Target ~= nil) then
if (ReplicatedStorage:FindFirstChild("[Part_Storage]") == nil) then
local Model = Instance.new ("Model", ReplicatedStorage);
Model.Name = "[Part_Storage]";
--Mouse.Target:SetAttribute("Source", Mouse.Target:GetFullName())
Mouse.Target:SetAttribute("Source", Mouse.Target.Name)
Mouse.Target.Parent = Model;
else
local Model = ReplicatedStorage:FindFirstChild("[Part_Storage]");
--Mouse.Target:SetAttribute("Source", Mouse.Target:GetFullName())
Mouse.Target:SetAttribute("Source", Mouse.Target.Name)
Mouse.Target.Parent = Model;
end
end
end
local function Part_Unhide()
if (ReplicatedStorage:FindFirstChild("[Part_Storage]") ~= nil) then
local Storage = ReplicatedStorage:FindFirstChild("[Part_Storage]");
for _, Child in pairs (Storage:GetChildren()) do
--local Source = Child:GetAttribute("Source");
--Child.Parent = Source
Child.Parent = Child:GetAttribute("Source"); -- <-- Cause of the issue
end
end
end
我不知道属性是否有办法接受实例作为值
Child.Parent = Child:GetAttribute("Source");
有没有办法将字符串转换为实例,或者将实例保存为值的替代方法,或者针对此问题的任何解决方法?如果是这样,感谢您的回答,在此先感谢!
【问题讨论】: