I have these bandages that I wanna attach to player.
This is the code that im working with but it doesnt work
local PS = game:GetService('Players')
local SS = game:GetService('ServerStorage')
local referenceDummy = SS.RLBRef
local function weld(partA, partB, character)
if character:IsA("Model") and character:FindFirstChild("Humanoid") then
local attachmentA = partA:FindFirstChild("Attachment")
local attachmentB = partB:FindFirstChild("RightKneeRigAttachment")
if attachmentA and attachmentB then
print("Ye")
local motor6D = Instance.new("Motor6D")
motor6D.Parent = partA
motor6D.Part0 = partA
motor6D.Part1 = partB
print(motor6D.Part1)
motor6D.C0 = attachmentA.CFrame
motor6D.C1 = CFrame.new(0, 0, 0)
return motor6D
else
warn("Attachments not found on parts")
end
else
warn("Invalid character")
end
end
local function onCharacterAdded(character)
local newWeld = referenceDummy.RightLegBandage:Clone()
newWeld.Parent = character
local weldPart = character:FindFirstChild("RightUpperLeg") or character:WaitForChild("RightUpperLeg", 5)
if weldPart then
weld(newWeld, weldPart, character)
else
warn("RightUpperLeg not found")
end
end
PS.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(onCharacterAdded)
end)
for _, player in pairs(PS:GetPlayers()) do
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
I did a thorough test, and figured out that Part1 gets assigned with partB only for a second and it gets disconnected at the end
Cant figure out why