Weld not working as expected

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m making a bullet mark, however I want it to weld to what it shoots at. I have the shooting mechanic done, however the welding just does not work

  1. What is the issue? Include screenshots / videos if possible!

The bullet mark does not stay, it appears where intended, then it falls out of the world.

Here’s the code:


----------------------------- Bullet Mark ---------------------

local function MakeBulletMark(hitpart, raycastResult)
		--Creating the bullet hole which will be cloned every time a hole needs to be made
		

		local bulletholepart = Instance.new("Part")
		bulletholepart.FormFactor = "Custom"
		bulletholepart.Size = Vector3.new(1, 1, 0.2)
				
		bulletholepart.Anchored = false
		bulletholepart.CanCollide = false
		bulletholepart.Transparency = 1
		
		local bulletholedecal = Instance.new("Decal", bulletholepart)
		bulletholedecal.Face = "Front" -- you want it to be in front of the part for later
		bulletholedecal.Texture = "http://www.roblox.com/asset/?id=2078626" --  a bullet hole decal I found 
		
		

		-- TO-DO: cast the ray
		local hit, pos, normal = hitpart, raycastResult.Position, raycastResult.Normal
		-- If I hit a wall, then
		local bullethole = bulletholepart:Clone()
		bullethole.Parent = game.Workspace

		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = hitpart
		Weld.Part0 = hitpart
		Weld.Part1 = bulletholepart
		Weld.Name = "BulletHoleWeld"
		print(Weld.Parent)
		print(Weld.Part0)
		print(Weld.Part1)
		--bulletholepart.Anchored = false
		bullethole.CFrame = CFrame.new(pos, pos + normal) -- the most important part: this sets the CFrame of the bullethole so that it's nearly flush with the wall. 
		game:GetService("Debris"):AddItem(bullethole, 10) -- automatically remove the bullet hole after 10 seconds
		-- TO-DO: do damage if it hits a player, etc.
	PhysicsService:SetPartCollisionGroup(bullethole, "Accesories")
end


-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------

Here’s the video of it not working:

I tried anchoring and then un-anchoring after the weld is made but it does not work. The weld is created but the decal seems to not recognize it I guess.

Try:

----------------------------- Bullet Mark ---------------------

local function MakeBulletMark(hitpart, raycastResult)
		--Creating the bullet hole which will be cloned every time a hole needs to be made
		

		local bulletholepart = Instance.new("Part")
		bulletholepart.FormFactor = "Custom"
		bulletholepart.Size = Vector3.new(1, 1, 0.2)
				
		bulletholepart.Anchored = false
		bulletholepart.CanCollide = false
		bulletholepart.Transparency = 1
		
		local bulletholedecal = Instance.new("Decal", bulletholepart)
		bulletholedecal.Face = "Front" -- you want it to be in front of the part for later
		bulletholedecal.Texture = "http://www.roblox.com/asset/?id=2078626" --  a bullet hole decal I found 
		
		

		-- TO-DO: cast the ray
		local hit, pos, normal = hitpart, raycastResult.Position, raycastResult.Normal
		-- If I hit a wall, then
		local bullethole = bulletholepart:Clone()
		bullethole.Parent = game.Workspace

		local Weld = Instance.new("Weld")
		Weld.Parent = hitpart
		Weld.Part0 = hitpart
		Weld.Part1 = bulletholepart
Weld.C1 = CFrame.new(pos, pos, normal)
		Weld.Name = "BulletHoleWeld"
		print(Weld.Parent)
		print(Weld.Part0)
		print(Weld.Part1)
		--bulletholepart.Anchored = false
		game:GetService("Debris"):AddItem(bullethole, 10) -- automatically remove the bullet hole after 10 seconds
		-- TO-DO: do damage if it hits a player, etc.
	PhysicsService:SetPartCollisionGroup(bullethole, "Accesories")
end


-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------

Try using C0/C1 for offsetting the weld

1 Like

Wait a minute the clone is bullethole

The original is bullet hole part

But the weld is setting to bullet hole part which is the original not the clone

2 Likes

This is actually the solution lol, but now when i shoot parts uh, move around…

At first I thought this was due to the ‘WeldConstraint’ I use, but even changing it to 'Weld" does not work :confused:

Consider making the part massless, if that doesn’t work store the CFrame and velocity before and after welding and reset it.

wait what would I be resetting? Also when I shoot my gun and the bullet mark is made it moves the part closer to me, not sure if that helps, but here’[s the current script:


local function MakeBulletMark(hitpart, raycastResult)
		--Creating the bullet hole which will be cloned every time a hole needs to be made
		

		local bulletholepart = Instance.new("Part")
		bulletholepart.FormFactor = "Custom"
		bulletholepart.Size = Vector3.new(1, 1, 0.2)
				
		bulletholepart.Anchored = false
		bulletholepart.CanCollide = false
		bulletholepart.Transparency = 0
		
		local bulletholedecal = Instance.new("Decal", bulletholepart)
		bulletholedecal.Face = "Front" -- you want it to be in front of the part for later
		bulletholedecal.Texture = "http://www.roblox.com/asset/?id=2078626" --  a bullet hole decal I found 
		
		

		-- TO-DO: cast the ray
		local hit, pos, normal = hitpart, raycastResult.Position, raycastResult.Normal
		-- If I hit a wall, then
		local bullethole = bulletholepart:Clone()
	bullethole.Parent = game.Workspace
	bullethole.Name = "BRUH"

		local Weld = Instance.new("Weld")
		Weld.Parent = hitpart
		Weld.Part0 = hitpart
		Weld.Part1 = bullethole
		Weld.Name = "BulletHoleWeld"
		Weld.C1 = CFrame.new(pos, pos, normal)
		print(Weld.Parent)
		print(Weld.Part0)
		print(Weld.Part1)
		--bulletholepart.Anchored = false
		bullethole.CFrame = CFrame.new(pos, pos + normal) -- the most important part: this sets the CFrame of the bullethole so that it's nearly flush with the wall. 
		game:GetService("Debris"):AddItem(bullethole, 10) -- automatically remove the bullet hole after 10 seconds
		-- TO-DO: do damage if it hits a player, etc.
	PhysicsService:SetPartCollisionGroup(bullethole, "Accesories")
end