【发布时间】:2022-01-03 03:32:33
【问题描述】:
有一个问题:当我运行这个脚本时,它什么也不做,什么也不输出,文件夹中的脚本位置和它检查同一个文件夹。
script.Parent.ChildAdded:connect(function()
print("block setup start")
local children = game.workspace["users assets"].blocks:GetChildren()
for i = 1, #children do
if not children[i]:FindFirstChild("ClickDetector") and children[i].Name ~= "setup" then
local cd = Instance.new("ClickDetector", children[i])
cd.MaxActivationDistance = 10
end
if not children[i]:FindFirstChild("BreakDown") and children[i].Name ~= "setup" then
local breac = script.BreakDown:Clone()
breac.Parent = children[i]
breac.BreakObject.Disabled = false
end
end
print("block setup succesfully")
end)
将部件添加到块文件夹的东西
local mouse = game.Players.LocalPlayer:GetMouse()
local debounce = false
mouse.KeyDown:Connect(function(key)
if key == "z" then
if debounce == false then
debounce = true
local part = Instance.new("Part",game.Workspace["users assets"].blocks)
part.Name = script.Parent.Parent.Name
part.Size = Vector3.new(3,3,3)
part.Anchored = true
part.CFrame = CFrame.new(mouse.Hit.X,mouse.Hit.Y + 1.5, mouse.Hit.Z)
part.Orientation = Vector3.new(0,0,0)
wait(1)
debounce = false
end
end
end)
【问题讨论】:
-
我假设这个脚本是 Workspace/users assets/blocks 的子脚本。您能否分享将内容添加到该文件夹的代码?
-
等一下..
-
有些东西会添加部件,并且设置脚本是块的有效子代。 local mouse = game.Players.LocalPlayer:GetMouse() local debounce = false mouse.KeyDown:Connect(function(key) if key == "z" then if debounce == false then debounce = true local part = Instance.new( "Part",game.Workspace["users assets"].blocks) part.Name = script.Parent.Parent.Name part.Size = Vector3.new(3,3,3) part.Anchored = true part.CFrame = CFrame.new(mouse.Hit.X,mouse.Hit.Y + 1.5, mouse.Hit.Z) part.Orientation = Vector3.new(0,0,0) wait(1) debounce = false end end end)