#Issues with welding sword to Left Arm
63 messages · Page 1 of 1 (latest)
Caan you show me the error in the output?
What is the error?
there is no error
thats the problem
i dont get any error but the cframe dosent change
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
^
And also, Weld Constraints are newer and simpler:
https://create.roblox.com/docs/reference/engine/classes/WeldConstraint
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
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
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.
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
https://medal.tv/games/roblox-studio/clips/P0YetTSBhijqC/d1337NdBmB5b?invite=cr-MSxPd0gsMTgyNDgzMjgs
Watch Untitled and millions of other Roblox Studio videos on Medal, the largest Game Clip Platform.
Line 18, maybe do:
clone.CFrame = leftarm.CFrame * CFrame.new(0, 15, 0)
getsword is just sitting in ReplicatedStorage I believe
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?
Hmm. sorry to ask but can you make another video? I think I'm having trouble understanding what's happening.
for sure give me one sec
https://medal.tv/games/roblox-studio/clips/P13L4m-bBi9QM/d1337gCmXnZb?invite=cr-MSx1d3QsMTgyNDgzMjgs
Watch Untitled and millions of other Roblox Studio videos on Medal, the largest Game Clip Platform.
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?
Yes, but I want to mention you might want to do things in this order:
- CFrame the clone to the position you want it in
- Set Part0 and Part1
- 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)
Hold on my good sir! lol I did some re-reading...
You're trying to have the player dual-wield something right?
yes
on tool equip it should weld the other sword to the players left arm giving it that effect
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.
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?
Apparently Weld was marked deprecated by accident in the past haha
Yes, it seems so.
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 😉
mhmm i see