Im having an issue with this script. It gets the children of the player's character, and then copies them, then it's supposed to get the children of the copies, and delete the Attachments in them but it wont. The attachments stay there and the character gets stuck. Here's my code:
script.Parent.Soru.OnServerEvent:Connect(function(Player, mousehit) if SoruCD == 0 and Player.NonStats.Stunned.Value == false and Player.Stats.SoruEXP.Value >= 5000 and Player.Stats.Stamina.Value >= 250 then local Range = 150 local Distance = (mousehit.p - Player.Character.UpperTorso.Position).Magnitude if Distance <= Range then SoruCD = 1 Player.Stats.Stamina.Value = Player.Stats.Stamina.Value - 250 Player.Character.UpperTorso.soru:Play() local direction = (mousehit.p - Player.Character.HumanoidRootPart.Position) * Vector3.new(1, 1, 1); direction = CFrame.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.Position + direction) Player.Character.HumanoidRootPart.CFrame = direction local Parts = Player.Character:GetChildren() for i,v in pairs(Parts) do if v.ClassName == "MeshPart" then local V = v:Clone() V.Parent = workspace V.BrickColor = BrickColor.new("Really black") V.Transparency = 0.5 V.Anchored = true V.CanCollide = false local Attachments = V:GetChildren() if Attachments.ClassName == "Attachment" then Attachments:Destroy() game:GetService("Debris"):AddItem(V, 2) Player.Character.UpperTorso.CFrame = CFrame.new(mousehit.p)*CFrame.new(0,5,0) wait(2) SoruCD = 0 end end end end end end)
any idea what could be causing this? Thanks for reading
local Attachments = V:GetChildren() if Attachments.ClassName == "Attachment" then
Attachments is a table of children, and you're forgetting to loop over it.