How can I prevent my system from overriding my character?

Hello! I recently made a bevel system for a game. It is fully completed but with one problem, the bevels override the characters. If you know what I mean. How do I fix this?

Expectation.

VS what I got.

The code

for i, v in pairs(workspace:GetDescendants()) do
	if v:IsA("Part") and not v:IsA("Model") then
		local part = v
		if part.Shape == Enum.PartType.Block then
			if not part:FindFirstChild("Bevel") then
				local bevel_cube = temp_cube:Clone()
				bevel_cube.Name = "Bevel"
				bevel_cube.Color = part.Color
				bevel_cube.Size = Vector3.new(2.5,2.5,2.5)
				bevel_cube.Parent = part
				bevel_cube.CFrame = part.CFrame
				
				for i , v in pairs(bevel_cube:GetChildren()) do
					if v:IsA("Bone") then
						v.CFrame = CFrame.new(0,0,0)
					end
				end
				part.Transparency = 1
				
				
				if part.Material == Enum.Material.Plastic then
					bevel_cube.Material = Enum.Material.SmoothPlastic
				end
				
				bevel_cube.FrontLeftTop.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/2,part.Size.Z/-2)
				bevel_cube.FrontRightTop.Transform = CFrame.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/-2)
				bevel_cube.BackLeftTop.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/2,part.Size.Z/2)
				bevel_cube.BackRightTop.Transform = CFrame.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2)

				bevel_cube.FrontLeftBottom.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/-2,part.Size.Z/-2)
				bevel_cube.FrontRightBottom.Transform = CFrame.new(part.Size.X/2,part.Size.Y/-2,part.Size.Z/-2)
				bevel_cube.BackLeftBottom.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/-2,part.Size.Z/2)
				bevel_cube.BackRightBottom.Transform = CFrame.new(part.Size.X/2,part.Size.Y/-2,part.Size.Z/2)

				local weld = Instance.new("WeldConstraint",part)
				weld.Part0 = bevel_cube
				weld.Part1 = part
			elseif part:FindFirstChild("Bevel") then
				return false
			end

		end
	end
end

What you can do is have an if statement to check if a model has a humanoid.

for i, v in pairs(workspace:GetDescendants()) do
	if v:IsA("Part") and not v:IsA("Model") and not v:FindFirstChildOfClass("Humanoid") then
		local part = v
		if part.Shape == Enum.PartType.Block then
			if not part:FindFirstChild("Bevel") then
				local bevel_cube = temp_cube:Clone()
				bevel_cube.Name = "Bevel"
				bevel_cube.Color = part.Color
				bevel_cube.Size = Vector3.new(2.5,2.5,2.5)
				bevel_cube.Parent = part
				bevel_cube.CFrame = part.CFrame
				
				for i , v in pairs(bevel_cube:GetChildren()) do
					if v:IsA("Bone") then
						v.CFrame = CFrame.new(0,0,0)
					end
				end
				part.Transparency = 1
				
				
				if part.Material == Enum.Material.Plastic then
					bevel_cube.Material = Enum.Material.SmoothPlastic
				end
				
				bevel_cube.FrontLeftTop.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/2,part.Size.Z/-2)
				bevel_cube.FrontRightTop.Transform = CFrame.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/-2)
				bevel_cube.BackLeftTop.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/2,part.Size.Z/2)
				bevel_cube.BackRightTop.Transform = CFrame.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2)

				bevel_cube.FrontLeftBottom.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/-2,part.Size.Z/-2)
				bevel_cube.FrontRightBottom.Transform = CFrame.new(part.Size.X/2,part.Size.Y/-2,part.Size.Z/-2)
				bevel_cube.BackLeftBottom.Transform = CFrame.new(part.Size.X/-2,part.Size.Y/-2,part.Size.Z/2)
				bevel_cube.BackRightBottom.Transform = CFrame.new(part.Size.X/2,part.Size.Y/-2,part.Size.Z/2)

				local weld = Instance.new("WeldConstraint",part)
				weld.Part0 = bevel_cube
				weld.Part1 = part
			elseif part:FindFirstChild("Bevel") then
				return false
			end

		end
	end
end
1 Like


Seems to be still occuring.

Fixed the problem.

					if part.Parent:FindFirstChildOfClass("Humanoid") then
					local bevel = part:WaitForChild("Bevel")
					bevel:Destroy()
					part.Transparency = 0
				end

I’ll mark this as the solution but thank you for your help Nico

1 Like

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