if char then
for i=1,5 do
local clone : Model = char:Clone()
for _, part in ipairs(clone:GetChildren()) do
if part:IsA("BasePart") then
clone.PrimaryPart.Transparency = 1
part:ClearAllChildren()
part.CanCollide = false
part.CanTouch = false
part.Massless = true
part.Anchored = true
end
end
clone:PivotTo(origin.CFrame * CFrame.new(0,2,0))
clone.Parent = workspace.Effects
task.wait(.05)
end
end
This is the code i use when i dash, it should position it correctly and remove cancollide, for some reason everything works except cancollide (Only for arms and legs), please tell me why?
There’s probably a humanoid state change happening in the clone. When humanoid state changes, the CanCollide properties of the bodyparts are automatically updated, which means the values you set are overwritten by the engine and you have to set them again.
local function doOtherChangesToBodyparts(charClone)
for _, part in ipairs(charClone:GetChildren()) do
if not part:IsA("BasePart") then
continue
end
part:ClearAllChildren()
part.CanTouch = false
part.Massless = true
part.Anchored = true
end
end
local function setCanCollideOfBodypartsToFalse(charClone)
for _, part in ipairs(charClone:GetChildren()) do
if not part:IsA("BasePart") then
continue
end
part.CanCollide = false
end
end
if char then
for i=1,5 do
local clone : Model = char:Clone()
clone.PrimaryPart.Transparency = 1
doOtherChangesToBodyparts(clone)
setCanCollideOfBodypartsToFalse(clone)
clone.Humanoid.StateChanged:Connect(function()
setCanCollideOfBodypartsToFalse(clone)
end
clone:PivotTo(origin.CFrame * CFrame.new(0,2,0))
clone.Parent = workspace.Effects
task.wait(.05)
end
end