So I essentially want to get all children from a folder and choose one child but all the children have the same name
Here’s what I used:
event.OnServerEvent:Connect(function()
local parts = partsFolder:GetChildren()
local randompart = parts[math.random(1, #parts)]
randompart:Destroy()
end)
The code works however, it selects all the parts instead of just a singular one. If anyone can point me in the right direction that would be great.
other scripts can be firing that remotevent, since u never specified any parameter it’ll fire that remotevent if you have something like this Remote:FireServer(“Parameter1”, “Parameter2”) etc
Yeah, the print statement in the fireserver script only print one, when fired.
It has to be an issue in the onserverevent script because those print statements are printed for how many parts there are in the folder. But I’m not sure what.
Show the script so we can check, also where is it parented? because if we use debounce in this issue it could cause some performance issue(it might not be noticeable now but who knows it might keep adding up in the future). The problem could also be the parent of the script being cloned thus also cloning the script inside it making it have multiple connections.
event.OnServerEvent:Connect(function()
local parts = partsFolder:GetChildren()
local randompart = parts[math.random(1, #parts)]
randompart:Destroy()
end)
for i,v in pairs(Workspace:GetChildren()) do
Event.OnServerEvent:Connect(function()
end)
end --- this will create multiple Connection depending on how many parts is in workspace.
You might want to put the whole script, usually multiple connections doesn’t really happen unless it’s caused by some flaw in the other parts of the code