Hello, I hope you are all having a good evening.
I have a slight issue with my game: my welds are breaking for no reason on different character meshes besides the basic one.
I have tried looking around on the Developer Hub to solve this issue, but to no avail.
Here is what I mean:
If I use my avatar I always use, it works as expected:
But, when I go ahead and use a different character with a different package, the welds break unexpectedly:
Here is my script where I create the weld (updated):
local character = player.Character or player.CharacterAdded:Wait()
player.CharacterAppearanceLoaded:Wait()
local torso = character.UpperTorso
local sword = game.ReplicatedStorage.Sword:Clone()
sword:PivotTo(torso.CFrame * CFrame.new(2, 1.5, torso.Size.Z / 2 + 0.05) * CFrame.Angles(math.rad(270), math.rad(-45), 0))
local weld = Instance.new("WeldConstraint", sword.Handle)
weld.Name = "SwordWeld"
weld.Part0 = weld.Parent
weld.Part1 = torso
sword.Parent = character
local onhand = player.Character:SetAttribute("equipped", false)
sword.Handle.Anchored = false
The script is a regular Script.
I'm stumped on this. It would be greatly appreciated if somebody could help me figure this out.
Ie_fishe
(paywalls)
2
Try to run this code when character fully loaded, my guess is when roblox loads in the package the weld breaks
1 Like
I will try this when I wake up in the morning.
Thank you for replying!
The good news is it welds now.
The bad news is it doesn’t position itself properly:
Edit: I forgot. Here’s the new script (nothing really changed):
local character = player.Character or player.CharacterAdded:Wait()
player.CharacterAppearanceLoaded:Wait()
local torso = character.UpperTorso
local sword = game.ReplicatedStorage.Sword:Clone()
sword:PivotTo(torso.CFrame * CFrame.new(2, 1.5, torso.Size.Z / 2 + 0.05) * CFrame.Angles(math.rad(270), math.rad(-45), 0))
local weld = Instance.new("WeldConstraint", sword.Handle)
weld.Name = "SwordWeld"
weld.Part0 = weld.Parent
weld.Part1 = torso
sword.Parent = character
local onhand = player.Character:SetAttribute("equipped", false)
sword.Handle.Anchored = false
I found out that I could prevent this issue by adding wait(2)
in the script:
local character = player.Character or player.CharacterAdded:Wait()
player.CharacterAppearanceLoaded:Wait()
wait(2)
local torso = character.UpperTorso
local sword = game.ReplicatedStorage.Sword:Clone()
sword:PivotTo(torso.CFrame * CFrame.new(2, 1.5, torso.Size.Z / 2 + 0.05) * CFrame.Angles(math.rad(270), math.rad(-45), 0))
local weld = Instance.new("WeldConstraint", sword.Handle)
weld.Name = "SwordWeld"
weld.Part0 = weld.Parent
weld.Part1 = torso
sword.Parent = character
local onhand = player.Character:SetAttribute("equipped", false)
sword.Handle.Anchored = false
Thank you, the one person for trying to help me.
Ie_fishe
(paywalls)
6
You can add 2 into :Wait
as it will wait 2 seconds after appearance is loaded
1 Like
Just tested it and it doesn’t wait 2 seconds after.
It probably will in a different scenario.
Appreciate the help though!