#Issues with welding sword to Left Arm

63 messages · Page 1 of 1 (latest)

toxic parcel
#

I'm trying to make a script where when I equip a tool it welds a cloned part inside of serverstorage to the players left arm i've got the welding working but when i add a cframe to it and change the values nothing moves i'm not getting any errors but the cframe dosen't work any idea why?

nova sluice
#

What is the error?

toxic parcel
#

there is no error

#

thats the problem

#

i dont get any error but the cframe dosent change

nova sluice
#

OOOOOH

#

The weld diesnt work like what yiu think buddy

#

Theres a property in weld

#

You should edit the C1 property of the weld to make the sword's sframe move

topaz parrot
#

^

#

Also, I can't help but notice you cloned the handle/sword INTO the left arm. Maybe just a peeve of mine, but I would rather place it inside the character model. Nesting a BasePart into a BasePart feels like a bad thing to do lol

toxic parcel
#

great suggestion ill start doing that

#

im guessing it would most likely be easier to just remake the script using weld constraints instead of regular welding

topaz parrot
#

I typically like using what the API suggests if it can do what I need because sooner or later they will slap a Deprecated tag on the "old stuff" and then they will be removed in the future.

toxic parcel
#

i tried to make a new script using weld constraints and using the stuff you said

#

i dont get any errors

#

but the weld dosent update to my leftarm

#

it just stays in place

#

example

topaz parrot
#

Line 18, maybe do:

clone.CFrame = leftarm.CFrame * CFrame.new(0, 15, 0)
#

getsword is just sitting in ReplicatedStorage I believe

toxic parcel
#

ahh thank you it works

#

i guess the last thing i'd be confused on is why the part just falls down from the sky

#

it dosent give the sword kinda of a anchor type feeling on the arm

#

so it just falls off

#

is there a way to make it to where the sword actually stays on my left arm?

topaz parrot
#

Hmm. sorry to ask but can you make another video? I think I'm having trouble understanding what's happening.

toxic parcel
#

for sure give me one sec

topaz parrot
#

Ahh okay. Lemme recreate

#

Ahh while recreating I noticed line 16 is setting Part1 to the sword in ReplicatedStorage and not the cloned one

#

Try that?

toxic parcel
#

so the script would look something like this correct?

topaz parrot
#

Yes, but I want to mention you might want to do things in this order:

  1. CFrame the clone to the position you want it in
  2. Set Part0 and Part1
  3. Parent the clone to the char
#

So something like this:

local tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local rs = game:GetService("ReplicatedStorage")
local getsword = rs:FindFirstChild("Handle2")
local clone = getsword:Clone()

tool.Equipped:Connect(function()
    
    local leftarm = char:FindFirstChild("Left Arm")
    local weld = Instance.new("WeldConstraint")
    
    clone.CFrame = leftarm.CFrame * CFrame.new(0, 0, 0)
    weld.Part0 = leftarm
    weld.Part1 = clone
    weld.Parent = leftarm
    clone.Parent = char
    
    print("the sword has been welded to your left arm")
end)
toxic parcel
#

ohhh ok i see

#

ill try that

topaz parrot
#

Hold on my good sir! lol I did some re-reading...

#

You're trying to have the player dual-wield something right?

toxic parcel
#

yes

#

on tool equip it should weld the other sword to the players left arm giving it that effect

topaz parrot
#

The original "Weld" might be better than "WeldConstraint" after all...

local tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local rs = game:GetService("ReplicatedStorage")
local getsword = rs:FindFirstChild("Handle2")
local clone = getsword:Clone()

tool.Equipped:Connect(function()
    
    local leftarm = char:FindFirstChild("Left Arm")
    local weld = Instance.new("Weld")
    
    weld.Part0 = clone
    weld.Part1 = leftarm
    weld.C0 = CFrame.new(0, 0, 1) * CFrame.Angles(math.rad(90), 0, 0) --edit me to reposition the cloned sword!
    weld.Parent = clone
    clone.Parent = char
    
    print("the sword has been welded to your left arm")
end)
#

Here's some code that reverts back to the old way for free, I'm sorry for leading you down this weird path haha.

#

Line 15 of that with the weld.C0 = ... bit is how you kinda offset the cloned sword relative to your player's arm's CFrame.

#

For example, right now I am rotating mine 90 degrees and moving it closer to my player's "hand" via editing the Z-axis. You should edit that CFrame as much as you need to position the sword correctly.

toxic parcel
#

ahhh i see thank you

#

but for later use why would i want to use weldconstraint over weld i couldnt really picture together the differences other than weld constraint missing the c.0 parameter

#

what does weldconstraint do opposed to regular weld?

topaz parrot
#

Apparently Weld was marked deprecated by accident in the past haha

toxic parcel
#

ohh ok

#

so its still usable today?

topaz parrot
#

Yes, it seems so.

toxic parcel
#

alr i see thank you for the help and information

#

i really appreciate it

topaz parrot
#

WeldConstraint is nice and easy when setting something that's done in studio and then has physics applied after the game is started. However, something like the user's arm moves around quite a bit in-game so the timing difference when the WeldConstraint binds the two items might have some slights errors in its placement.

#

With the C0 and C1 properties you can EXPLICITLY set their position in reference to the part as opposed to having the engine lock it in place at that moment in time (which could be slightly off due to physics still applying to the part and your arms swinging around)

#

There's something lost due to the convenience and that's accuracy 😉

toxic parcel
#

mhmm i see