Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The Weld Script Welds it Straight, How do i change the position of the weld?

So the Scripts i have, That makes it so the Sword appears the on players back, and they can Draw their sword, Which makes the sword appear in the players hand, but just straight up into their arm, How do i fix this? Im using the qPerfection Weld Script and 2 others.

QPerfection Weld: You can search it on the toolbox menu.

Weld:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local weldpart = game:GetService("ReplicatedStorage").Sword:Clone()
		weldpart.Parent = char
		local weld = Instance.new("Weld",weldpart.BackWeld)
		weld.Part0 = char.UpperTorso
		weld.Part1 = weldpart.BackWeld
	end)
end)

WeldAfter:

game.ReplicatedStorage:WaitForChild("EquipEvent").OnServerEvent:Connect(function(player,Equipped)
	local holdanim = Instance.new("Animation")
	holdanim.AnimationId = game:GetService("ReplicatedStorage"):WaitForChild("SwordConfiguration").Hold.Value
	local holdanimtrack = player.Character.Humanoid:LoadAnimation(holdanim)
	if Equipped then
		print("Equipped")
		local anim = Instance.new("Animation")
		anim.AnimationId = game:GetService("ReplicatedStorage"):WaitForChild("SwordConfiguration").Equip.Value
		local animtrack = player.Character.Humanoid:LoadAnimation(anim)
		animtrack:Play()
		wait(.480)
		player.Character.Sword.Sword.Unsheath:Play()
		player.Character.Sword.BackWeld.Weld:Destroy()
		local newWeld = Instance.new("Weld",player.Character.Sword.Handle)
		newWeld.Part0 = player.Character.Sword.Handle
		newWeld.Part1 = player.Character.RightHand
		wait(.3)
		animtrack:Stop()
		anim:Destroy()
		holdanimtrack:Play()
	elseif not Equipped then
		print("UnEquipped")
		holdanimtrack:Stop()
		local anim = Instance.new("Animation")
		anim.AnimationId = game:GetService("ReplicatedStorage"):WaitForChild("SwordConfiguration").UnEquip.Value
		local animtrack = player.Character.Humanoid:LoadAnimation(anim)
		animtrack:Play()
		wait(.418)
		player.Character.Sword.Sword.Sheath:Play()
		wait(0.062)
		player.Character.Sword.Handle.Weld:Destroy()
		local newWeld = Instance.new("Weld",player.Character.Sword.BackWeld)
		newWeld.Part0 = player.Character.Sword.BackWeld
		newWeld.Part1 = player.Character.UpperTorso
		wait(.3)
		animtrack:Stop()
		anim:Destroy()	
	end
end)

Also, The Animations in the Settings folder of the script that runs the sword, Whenever you equip / unequip or click, It doesn't play the animation! Please help!

10 comments

0

Oh im very sorry, The script has comments on it so it breaks on website... Im so sorry.

0

And, If you want i can show all the stuff in the sword, scripts that run it etc

0

For me, The sword kept falling apart tilll i added Quenty's Weld script

0

If you're using a normal weld, you're going to need to specify the weld.C0: "newWeld.C0 = newWeld.Part0.CFrame:inverse() * newWeld.Part1.CFrame * CFrame.new(THIS IS YOUR OFFSET (CAN BE 0,0,0 FOR NO OFFSET) )"

0

hi sorry didnt see your comment. yea, you'll need something like quenty's weld script to weld all the parts together. the issue is you're not specifying the weld.C0. 

0

Where do i put "newWeld.C0 = newWeld.Part0.CFrame:inverse() * newWeld.Part1.CFrame * CFrame.new"? Also, i tried just using Weld Constraint and it just kept the handle and blade, I have multiable parts in handle blade

0

right after you specify part1 and part2. also, here's a good welding script my friend made. it has a function which shows how to weld using "Weld" https://pastebin.com/raw/K4X2cnDm

0

I have, so wheres the equation you gave me?

0

what do you mean? and it's a bit hard to talk in the comments? is there any chance you can talk over discord? Lucy#0003

0

Cliffhanger#8164

1 answer

✓ Accepted answer

Here's the weld function I linked in the comments:

local function createWeld(part0, part1, weldType, offset)
    local weld = Instance.new(weldType or "Weld")
    
    offset = offset or CFrame.new()
    
    weld.Part0 = part0
    weld.Part1 = part1
    weld.C0 = part0.CFrame:inverse() * part1.CFrame * offset
    weld.Parent = part0
    
    return weld
end

To put the sword onto the player's hand, we'd want to rotate the sword so it's in front of the player and then weld it. How you rotate it depends on how the handle is rotated by the way.

Visual of how we're rotating it: https://i.imgur.com/mz9dFco.png

--position sword to hand		
sword.Handle.CFrame = player.Character.RightHand.CFrame
					* CFrame.Angles(math.rad(-90),0,0)
					* CFrame.new(0,0,-player.Character.RightHand.Size.Y/2) 
					* CFrame.Angles(0,math.rad(90),0)
							
--create the new weld using function above
local weld = createWeld(sword.BackWeld, player.Character.RightHand)

This discussion is preserved as it was. New answers, comments, and votes are closed.