Collision doesn't turn off no matter what I do

  1. What do you want to achieve?
    I have code that generates a clone of a character or part in all clients, for skill graphic purposes, but for some reason this clone collides even though I am placing it in another collisiongroup and disabling its collision.

Code:

	local function CloneEffect(Table)

		if Table == nil or Table["Character"] == nil then return end

		Table["Character"].Archivable = true
		local DCharacter = Table["Character"]:Clone()
		DCharacter:SetAttribute("CloneEffect", true)

		if DCharacter then

			for _, v in pairs(DCharacter:GetDescendants()) do
				if v:IsA("Script") or v:IsA("Decal") or v:IsA("LocalScript") or v:IsA("ModuleScript") or v:IsA("Folder") or v:IsA("ParticleEmitter") or (v:IsA("Part") and v.CollisionGroup == "Ragdoll") then
					v:Destroy()

				end

			end

			local Highlight = Instance.new("Highlight")
			Highlight.DepthMode = Table["DepthMode"] or Enum.HighlightDepthMode.Occluded
			Highlight.FillTransparency = Table["FillTransparency"] or 0.1
			Highlight.FillColor = Table["FillColor"] or Color3.fromRGB(255, 255, 255)
			Highlight.OutlineTransparency = Table["OutlineTransparency"] or 0.5
			Highlight.OutlineColor = Table["OutlineColor"] or Color3.fromRGB(0, 0, 0)
			Highlight.Parent = DCharacter

			if DCharacter:IsA("Part") then

				DCharacter.Anchored = true
				DCharacter.CanTouch = false
				DCharacter.CanQuery = false
				DCharacter.Massless = true
				DCharacter.CanCollide = false
				DCharacter.CollisionGroup = "Assets"
				DCharacter.Transparency = Table["PartTransparency"] or 0.5

			end

			for _, Object in pairs(DCharacter:GetDescendants()) do

				if Object:IsA("Part") then
					Object.Anchored = true
					Object.CanTouch = false
					Object.CanQuery = false
					Object.Massless = true
					Object.CanCollide = false
					Object.CollisionGroup = "Assets"

					if Object.Transparency >= 0.95 then continue end

					Object.Transparency = Table["PartTransparency"] or 0.5

				end

				if Object:IsA("Decal") then
					Object.Transparency = Table["PartTransparency"] or 1.0

				end

			end

			if typeof(Table["Duration"]) == "Instance" then

				Table["Duration"].AncestryChanged:Connect(function()

					if Table["Duration"] == nil or Table["Duration"].Parent == nil then

						local Tween = TSE:Create(Highlight, TweenInfo.new(0.5), {["FillTransparency"] = 1})
						Tween:Play()

						if DCharacter:IsA("Part") then

							local Tween = TSE:Create(DCharacter, TweenInfo.new(0.5), {["Transparency"] = 1})
							Tween:Play()

						end

						for _, Object in pairs(DCharacter:GetDescendants()) do

							if Object:IsA("Part") or Object:IsA("Decal") then

								local Tween = TSE:Create(Object, TweenInfo.new(0.5), {["Transparency"] = 1})
								Tween:Play()

							end

						end

						Tween.Completed:Connect(function()

							DCharacter.Parent = nil
							DCharacter:Destroy()

						end)

					end

				end)

			elseif typeof(Table["Duration"]) == "number" then 

				task.delay(Table["Duration"], function()

					local Tween = TSE:Create(Highlight, TweenInfo.new(0.5), {["FillTransparency"] = 1.0})
					Tween:Play()

					if DCharacter:IsA("Part") then

						local Tween = TSE:Create(DCharacter, TweenInfo.new(0.5), {["Transparency"] = 1})
						Tween:Play()

					end

					for _, Object in pairs(DCharacter:GetDescendants()) do

						if Object:IsA("Part") or Object:IsA("Decal") then

							local Tween = TSE:Create(Object, TweenInfo.new(0.5), {["Transparency"] = 1})
							Tween:Play()

						end

					end

					Tween.Completed:Connect(function()

						DCharacter.Parent = nil
						DCharacter:Destroy()

					end)

				end)

			end

			DCharacter.Parent = workspace.Assets

		end

	end

Alright, so certain objects within a character will always be can collide true

I’m not sure if that is your problem here but there is an easy fix no matter what the problem is.

physics service, allows you to set different groups collidable
In this case you will have to register a new group such as (DoNotCollideWithDefault)
and set this group and Default (which is everything else) to not collide with eachother
This way even if cancollide is on they will not collide with eachother!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.