Weld / Collision issue

  1. What do you want to achieve? Keep it simple and clear!
    The tower’s RangeBox not to be malfunctioning, and have no collisions to other objects.

This is a demonstration of a Non-Humanoid:
robloxapp-20220221-1120096.wmv (3.5 MB)

  1. What is the issue? Include screenshots / videos if possible!
    Some sort of collision error or weld, I don’t know. It get’s pushed away from any object.
    robloxapp-20220221-1121370.wmv (3.1 MB)
    It also doesn’t move the RangeBox when placed, either:
    image
    (Ignore the zombies)

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

--There is a bunch of code above it. This simply handles collisions etc
RunService.RenderStepped:Connect(function()
	if TowerToSpawn then
		local result = MouseRaycast({TowerToSpawn})
		if result and result.Instance then
			local GetRangeBoxTouchingParts = TowerToSpawn.RangeBox:GetTouchingParts()

			if result.Instance.Parent.Name == "TowerArea" then
				CanPlace = true
				ColorPlaceholderTower(Color3.new(0,1,0))
			else
				CanPlace = false
				ColorPlaceholderTower(Color3.new(1,0,0))
			end
			
						for index, part in ipairs(GetRangeBoxTouchingParts) do
				if part.Name == "RangeBox" and part.Parent ~= TowerToSpawn then
					CanPlace = false
					ColorPlaceholderTower(Color3.new(1,0,0))
				end
			end
			
			local x = result.Position.X
			local y
			if TowerToSpawn.Humanoid.RigType == Enum.RigType.R15 then
				y = result.Position.Y + TowerToSpawn.Humanoid.HipHeight + (TowerToSpawn.PrimaryPart.Size.Y / 2)
			else
				y = TowerToSpawn:GetExtentsSize().Y / 2
			end
			local z = result.Position.Z


			local cframe = CFrame.new(x,y,z) * CFrame.Angles(0, math.rad(Rotation), 0)
			TowerToSpawn:SetPrimaryPartCFrame(cframe)
			PhysicsService:SetPartCollisionGroup(TowerToSpawn.Range,"Tower")
			PhysicsService:SetPartCollisionGroup(TowerToSpawn.RangeBox,"TowerBox")
			TowerToSpawn.Range.Size = Vector3.new(0.1, TowerToSpawn.Levels[TowerToSpawn.CurrentLevel.Value].Range.Value * 2, TowerToSpawn.Levels[TowerToSpawn.CurrentLevel.Value].Range.Value * 2)
		end
	end
end)

image

1 Like

Hello? I’ve been trying to find the issue for hours now. It be nice if someone helped.

1 Like

Why do you need collision groups?

1 Like

I use it multiple times in the script to avoid collisions with the zombies and players, but still have collisions for everything else.

So the problem is when you place a tower it is colliding with other things and being placed elsewhere?

1 Like

Kind of. Watch the video I provided, it shows what I’m talking about.

Sorry, but the first one is a nonhumanoid and the second has a humanoid??

1 Like

The one in the video has no humanoid. I’ll get a video of the humanoid

Why not use an AnimationController and just take out the the Humanoid altogether?

Pardon? I have no idea what you mean.

Yeah, Roblox has an AnimationController for models and NPCs so all you have to do is add an Animator and play it from there.

https://developer.roblox.com/en-us/api-reference/class/AnimationController

By “humanoid” I think you are mixed up with Humanoids. I am talking about HumanoidRootPart.

1 Like

I am not using animations. How would this help?

Oh I thought you were using a Humanoid to load animations.

1 Like

I mean I’m not too sure but the part just looks unanchored to me

1 Like

It’s welded to MainPart. Exactly the same as the one in the video.

Okay wait so there is no Humanoid and it’s welded to the Main Part and you are doing SetPrimaryPartCFrame right?

1 Like

There are both a Humanoid and a HumanoidRootPart in the current model with the issue.

I don’t understand. Why would you need a Humanoid? let alone a HumanoidRootPart xd

1 Like

Animations - Humanoid to load them and animate.

1 Like