I have a modules script setup that should weld a piece of armor to the player by descending the list of children in a group and setting a value to the name of each child and then welding everything to the aforementioned body part. The script works right up to the actual welding process. After line 63 in the module script, nothing seems to happen. Thanks in advance for any help!
Both Scripts are located in ServerScriptService
The Server Script
function onSpawn(player)
local char = game.ReplicatedStorage["newPlayer"]:Clone()
local SpawnLocation = game.Workspace.SpawnLocation
char.Parent = workspace
char.Name = player.Name
char:MoveTo(SpawnLocation.Position)
player.Character = char
local human = char:WaitForChild("Humanoid")
human.WalkSpeed = 10
local already_ran = false
local grounded = false
function onGround(speed)
if grounded == false then
grounded = true
end
player.Character.Humanoid.Running:connect(onGround)
end
end
function Attire()
end
game.Players.PlayerAdded:connect(function(player)
local T = game.ServerStorage.StarterPlayerKit
T:Clone().Parent = player.PlayerGui
onSpawn(player)
local Module = require(game.ServerScriptService.WeldModule)
print("Module_Booted FrontEnd")
Module.CycleWeld(player)
print("Module_Completed FrontEnd")
end)
The Module
function weld(p1,p2,c0)
local w = Instance.new("Weld",p1)
w.Part0 = p1
w.Part1 = p2
w.C0 = c0 or p1.CFrame:inverse() * p2.CFrame
return w
end
function PerformWeld(player)
local DataLoad = player.Character:WaitForChild("PlayerData")
local PlayerAttire = DataLoad:FindFirstChild("AttireData")
local WD = DataLoad.WeldingAids:FindFirstChild("WeldData")
local Weldee = DataLoad.WeldingAids.Weldee
local PE = player.Character:FindFirstChild("PlayerEquipment")
local Outfit = game.ServerStorage:FindFirstChild(Weldee.Value):Clone()
local char = player.Character or player.CharacterAdded:wait()
local Garment = Outfit:WaitForChild(WD.Value.."Components")
local CurrentSection = Garment:Clone()
CurrentSection.Parent = char
for _,v in pairs(CurrentSection:GetChildren()) do
if v.ClassName == "Part" or v.ClassName == "UnionOperation" then
v.Anchored = true
end
end
CurrentSection.Parent = PE
for _,v in pairs(CurrentSection:GetChildren()) do
if v.ClassName == "Part" or v.ClassName == "UnionOperation" then
if v ~= CurrentSection["ArmorCore"] then
weld(v, CurrentSection["ArmorCore"])
end
end
end
local CurrentSectionWeld = weld(CurrentSection["ArmorCore"], char[WD.Value], CFrame.new())
for _,v in pairs(CurrentSection:GetChildren()) do
if v.ClassName == "Part" or v.ClassName == "UnionOperation" then
v.Anchored = false
v.CanCollide = false
print ("Welded "..WD.Value)
end
end
end
local WeldModule = {}
function WeldModule.CycleWeld(player)
print("Module_Booted")
local DataLoad = player.Character:WaitForChild("PlayerData")
local WD = DataLoad.WeldingAids:FindFirstChild("WeldData")
local C = player.Character
local children = C.UpperBodyParts:GetChildren()
print("Data_Established"..player.Name)
for v = 1, #children do
if children.ClassName == "Part" or children.ClassName == "UnionOperation" then
WD.Value = children.Name
print("Weld_Booted")
PerformWeld(player)
print("Welded")
wait(0.2)
end
end
end
return WeldModule
