Hello,
I have a script that must get the descendants of a folder in the workspace.
but the problem its that the script skip some descendants.
script.Parent.MouseButton1Click:Connect(function()
print("click")
wait(5)
for _, v in pairs(game.Workspace.ToolModels:GetDescendants()) do
print(v)
if v:FindFirstChild("ClickDetetor") then
print("find Detector")
local clickScript = game.ReplicatedStorage:WaitForChild("Scripts"):FindFirstChild("Script"):Clone()
clickScript.Parent = v.Parent
clickScript.Disabled = false
end
end
end)
When you switch to server the gun disappears from the workspace. So that means that the gun is local. You must add the gun through the server (workspace, replicatedstorage, etc) to avoid this
script.Parent.MouseButton1Click:Connect(function()
print("click")
wait(5)
for _, v in pairs(game.Workspace.ToolModels:GetDescendants()) do
print(v)
if v:IsA("ClickDetector") then
print("find Detector")
local clickScript = game.ReplicatedStorage:WaitForChild("Scripts"):FindFirstChild("Script"):Clone()
clickScript.Parent = v.Parent
clickScript.Disabled = false
end
end
end)
because it’s looping through the descendants?
also, cloning server scripts from local scripts wouldn’t work because it’s a local change, the server wouldn’t see it and the code won’t run
but the main problem that I switch to Script for clone the script(the script into ReplicatedStorage) that I want and not with a LocalScript, because when the script(the script into ReplicatedStorage) its cloned with a LocalScript its get broke (its don’t want work)
do you guys have a simple and fast solution for this?