Weld breaks when used on opposite player

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 want it so it attaches 2 players together with a weld while playing an animation

  2. What is the issue? Include screenshots / videos if possible!
    The animation breaks when the opposite player attaches it

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve search on the dev forum and the only solution I found was to make them massless but it doesnt work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local skill = {}
local serverStorage = game:GetService('ServerStorage')
local mainModule = require(serverStorage:WaitForChild("ServerModules"):WaitForChild("Main"))
local hitboxModule = require(serverStorage:WaitForChild("ServerModules"):WaitForChild("Hitbox"))
local knockbackModule = require(serverStorage:WaitForChild("ServerModules"):WaitForChild("Knockback"))
local repStorage = game:GetService("ReplicatedStorage")
local animations = repStorage.Animations
function skill.Use(player : Player)
	local character = player.Character
	local attacking = true
	local endLag = 0.6
	local anim = mainModule.playAnim(animations.Start,character.Humanoid.Animator)
	task.spawn(function()
		while attacking == true do
			task.wait()
			if mainModule:isStunned(character) then
				anim:Stop(0)
				break
			end
		end
		attacking = false
		mainModule.removeDebounce(character)
	end)
	mainModule.addDebounce(character, {CanMove = false})
	task.wait(0.3)
	local hitbox = hitboxModule.createHitbox(Vector3.new(5,3,5))
	hitbox.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
	game:GetService("Debris"):AddItem(hitbox,0.2)
	local hitPlayers = mainModule:getPlayersInHitbox({Character = character, Hitbox = hitbox})
	local victimAnim = nil
	if hitPlayers and attacking then
		for _, v in ipairs(hitPlayers) do
			if mainModule:isRagdolled(v) then
				mainModule.ragdoll(v,false)
			end
		end
		mainModule.removeDebounce(character)
		mainModule.addDebounce(character, {CanMove = false,CanRotate = false})

		mainModule.damagePlayers({
			Attacker = character,
			Victims = hitPlayers[1],
			Damage = 0,
			Stun = 2.6,
			DisableRotate = true,
			HurtFunction = function()
				victimAnim = mainModule.playAnim(animations.ThrashSpinVictim,hitPlayers[1].Humanoid.Animator)
			end,
		})		
		task.wait()
		if not attacking then return end
		hitPlayers[1].HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(180),0)
		mainModule.playAnim(animations.Spin,character.Humanoid.Animator)		
		if hitPlayers[1].Parent ~= nil then
			hitPlayers[1].HumanoidRootPart:SetNetworkOwner(player)
		end
		local weld = Instance.new("Weld")
		weld.Part0 = hitPlayers[1].HumanoidRootPart
		weld.Part1 = character.Torso
		weld.C1 = CFrame.new(0,0,-4) * CFrame.Angles(0,math.rad(180),0)
		weld.Parent = hitPlayers[1].HumanoidRootPart
		game:GetService("Debris"):AddItem(weld,2.3)
		for _, v in ipairs(hitPlayers[1]:GetChildren()) do
			if v:IsA("BasePart") then
				v.CollisionGroup = "NoCollision"
			--	v.Massless = true
		--		v.Anchored = false
			--	v.CanCollide = false
			end
		end
		for _, v in ipairs(character:GetChildren()) do
			if v:IsA("BasePart") then
				v.CollisionGroup = "NoCollision"
		--		v.Massless = true
		--		v.Anchored = false
			--	v.CanCollide = false
			end
		end
		task.wait(2.5)
		local victimPlayer = game:GetService("Players"):GetPlayerFromCharacter(hitPlayers[1])
		if victimPlayer then
			hitPlayers[1].HumanoidRootPart:SetNetworkOwner(victimPlayer)
		else
			hitPlayers[1].HumanoidRootPart:SetNetworkOwner(nil)
		end
		for _, v in ipairs(hitPlayers[1]:GetChildren()) do
			if v:IsA("BasePart") then
				v.CollisionGroup = "Player"
				v.Massless = false
			--	if v.Name == "Torso" or v.Name == "HumanoidRootPart" then
			--		v.CanCollide = true
			--	else
			--		v.CanCollide = false
			--	end
			end
		end
		for _, v in ipairs(character:GetChildren()) do
			if v:IsA("BasePart") then
				v.CollisionGroup = "Player"
				v.Massless = false
			--	if v.Name == "Torso" or v.Name == "HumanoidRootPart" then
		--			v.CanCollide = true
			--	else
			--		v.CanCollide = false
			--	end
			end
		end
		if not attacking then return end
		hitPlayers[1].HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(90),0)
		mainModule.damagePlayers({
			Attacker = character,
			Victims = hitPlayers[1],
			Damage = 0,
			Ragdoll = true,
			RagdollTime = 4,
		})		
		victimAnim:Stop(0)
		task.delay(1, function()
			local rayParams = RaycastParams.new()
			rayParams.FilterType = Enum.RaycastFilterType.Include
			rayParams.FilterDescendantsInstances = {workspace.Baseplate}
			while mainModule:isRagdolled(hitPlayers[1]) do
				local raycast = workspace:Raycast(hitPlayers[1].HumanoidRootPart.Position,Vector3.new(0,-5,0),rayParams) 
				if raycast then
					mainModule.damagePlayers({
						Attacker = character,
						Victims = hitPlayers[1],
						Damage = 15,
						Ragdoll = true,
						RagdollTime = 2
					})		
					break
				end
				task.wait()
			end
		end)
		local lookVector = hitPlayers[1].HumanoidRootPart.CFrame.LookVector
		local velocity = Vector3.new(lookVector.X*-50,50,lookVector.Z*-50)
		knockbackModule.addVelocity({
			Velocity = velocity,
			VelocityTime = 0.5,
			VelocityPlayer = hitPlayers[1]
		})
	end
	task.wait(endLag)
	attacking = false
end

return skill

Any help is appreciated because I dont understand what I’m doing wrong here.

Found out I just needed to anchor the player to fix it. It works fine now

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