What do you want to achieve? I want my script to create clones that will have CanCollide to False
What is the issue? Though i added descendants.CanCollide = false, it don’t work yet
What solutions have you tried so far? ai, forums, friends
I only need help with making clones uncollideable, everything else that’s wrong with script is unnecessary
-- local Enumeration = Enum
local Game = game
local Workspace = workspace
local Debris = Game:GetService("Debris")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local TweenService = Game:GetService("TweenService")
local function SetPartsNonCollidable(model)
-- Iterate through all descendants of the model
for _, descendant in ipairs(model:GetDescendants()) do
if descendant:IsA("BasePart") and descendant.Name ~= "CameraPart" and descendant.Name ~= "HumanoidRootPart" then
descendant.Anchored = true
descendant.CastShadow = false
descendant.CanCollide = false -- Set CanCollide to false
descendant.Material = Enumeration.Material.Neon
descendant.Transparency = 0
end
end
end
local function OnCharacterAdded(Character)
Character.Archivable = true
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local cloneCounter = 0 -- Counter for unique names
while true do
task.wait()
if not Character.Parent then break end
if Humanoid.MoveDirection.Magnitude == 0 then continue end
-- Clone the character
local CharacterClone = Character:Clone()
-- Ensure all parts and models are non-collidable and transparent
SetPartsNonCollidable(CharacterClone)
-- Assign a unique name to the clone
cloneCounter = cloneCounter + 1
CharacterClone.Name = "CharacterClone_" .. cloneCounter
-- Position the clone
CharacterClone:PivotTo(Character:GetPivot())
CharacterClone.Parent = Workspace
-- Tween to gradually change transparency from 0.8 to 1
for _, Descendant in ipairs(CharacterClone:GetDescendants()) do
if Descendant:IsA("BasePart") and Descendant.Name ~= "CameraPart" and Descendant.Name ~= "HumanoidRootPart" then
local TweenInfo = TweenInfo.new(
2, -- Time (2 seconds)
Enumeration.EasingStyle.Linear, -- EasingStyle
Enumeration.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (0 means no repeat)
false, -- Reverses (false means it won't reverse)
0 -- DelayTime
)
local TweenGoal = {Transparency = 1}
local Tween = TweenService:Create(Descendant, TweenInfo, TweenGoal)
Tween:Play()
-- Connect completion to deletion
Tween.Completed:Connect(function()
Descendant:Destroy()
end)
end
end
task.wait(0.1)
-- Remove the character clone from the workspace after 2.1 seconds
Debris:AddItem(CharacterClone, 2.1)
end
end
Player.CharacterAdded:Connect(OnCharacterAdded)
You can use physics service to register group then disabling it collison with itself:
Client:
-- local Enumeration = Enum
local Game = game
local Workspace = workspace
local Debris = Game:GetService("Debris")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local TweenService = Game:GetService("TweenService")
local function SetPartsNonCollidable(model)
-- Iterate through all descendants of the model
for _, descendant in ipairs(model:GetDescendants()) do
if descendant:IsA("BasePart") and descendant.Name ~= "CameraPart" and descendant.Name ~= "HumanoidRootPart" then
descendant.Anchored = true
descendant.CollisionGroup = "NonTouchable"
descendant.CastShadow = false
descendant.CanCollide = false -- Set CanCollide to false
descendant.Material = Enum.Material.Neon
descendant.Transparency = 0
end
end
end
local function OnCharacterAdded(Character)
Character.Archivable = true
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local cloneCounter = 0 -- Counter for unique names
for _,v in pairs(Character:GetDescendants()) do
if v:IsA('BasePart') then
v.CollisionGroup = "NonTouchable"
end
end
while true do
task.wait()
if not Character.Parent then break end
if Humanoid.MoveDirection.Magnitude == 0 then continue end
-- Clone the character
local CharacterClone = Character:Clone()
-- Ensure all parts and models are non-collidable and transparent
SetPartsNonCollidable(CharacterClone)
-- Assign a unique name to the clone
cloneCounter = cloneCounter + 1
CharacterClone.Name = "CharacterClone_" .. cloneCounter
-- Position the clone
CharacterClone:PivotTo(Character:GetPivot())
CharacterClone.Parent = Workspace
-- Tween to gradually change transparency from 0.8 to 1
for _, Descendant in ipairs(CharacterClone:GetDescendants()) do
if Descendant:IsA("BasePart") and Descendant.Name ~= "CameraPart" and Descendant.Name ~= "HumanoidRootPart" then
local TweenInfo = TweenInfo.new(
2, -- Time (2 seconds)
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (0 means no repeat)
false, -- Reverses (false means it won't reverse)
0 -- DelayTime
)
local TweenGoal = {Transparency = 1}
local Tween = TweenService:Create(Descendant, TweenInfo, TweenGoal)
Tween:Play()
-- Connect completion to deletion
Tween.Completed:Connect(function()
Descendant:Destroy()
end)
end
end
task.wait(0.1)
-- Remove the character clone from the workspace after 2.1 seconds
Debris:AddItem(CharacterClone, 2.1)
end
end
Player.CharacterAdded:Connect(OnCharacterAdded)
Server:
local PhysicsService = Game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("NonTouchable")
PhysicsService:CollisionGroupSetCollidable("NonTouchable","NonTouchable",false)