How to make sure my weld script works everytime?

I have this watch weld script that works, 25 percent of the time, other times the part its welding falls to the ground, any way to make it fully weld and 100 percent of the time? Here is the script.

local BlackWatch = game.ServerStorage.Watchs.Watch
  
game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
	if player:WaitForChild("leaderstats").Watch.Value == 1 then
		print("FENDIII")
		wait(1)
		local newRadio = BlackWatch:Clone()
		newRadio.Parent = character
		newRadio.CFrame = character.LeftLowerArm.CFrame * CFrame.Angles(0,3.14,6) -- or Torso if you use R6
		local weld = Instance.new("Weld") 
		weld.Part0 = newRadio
		weld.Part1 = character.LeftLowerArm
		weld.C0 =newRadio.CFrame:inverse() 
		weld.C1 = character.LeftLowerArm.CFrame:inverse() 
		weld.Parent = newRadio	
    end
	end)
	end)

Why don’t you set the part anchored while you weld it to make sure it stays where you want it and then unanchor it when you have finished the weld?
Also, why aren’t you using the new WeldConstraint? Old Weld is deprecated I believe.

BTW if the script already works why didn’t you put this is #development-support:code-review?

Ill try that, and my bad haha.

The simple answer here is actually to weld first before you parent. Don’t go through that anchor nonsense, you don’t need to at all. So long as the part isn’t in the Workspace, it isn’t physically simulated. Weld first, parent model after.

		local newRadio = BlackWatch:Clone()
		newRadio.CFrame = character.LeftLowerArm.CFrame * CFrame.Angles(0,3.14,6) -- or Torso if you use R6
		local weld = Instance.new("Weld") 
		weld.Part0 = newRadio
		weld.Part1 = character.LeftLowerArm
		weld.C0 =newRadio.CFrame:inverse() 
		weld.C1 = character.LeftLowerArm.CFrame:inverse() 
		weld.Parent = newRadio
		newRadio.Parent = character

Fixed code for you.


@GreekForge Old welds are not deprecated…

OP doesn’t need to use WeldConstraints and posting this thread in Code Review would be miscategorisation.

1 Like