I'm pretty much a noob when it comes to scripting so.... yeah. I made this csg gun that I scaled down to tool level. I manually welded everything via script, but when the player picks it up, un-equips it and equips it again, it falls apart. My attempts at trying to re-weld have failed. I just can't find a way to parent it to the character! If anyone can solve my question or if they have a better solution, I'm all ears. Oh, yeah, I almost forgot my other question! If anyone can put code of a projectile script in, that would be nice ;)
Try to weld when it Equips and unequips using
script.Parent.Equipped and script.Parent.Unequipped
More info on my script, this is the ENTIRE thing (plus commented out part):
local Handle = workspace.Smg1.Handle local LoadingMech = workspace.Smg1.LoadingMech local Magazine = workspace.Smg1.Magazine local NonMoving = workspace.Smg1.NonMoving local Stock = workspace.Smg1.Stock local Trigger = workspace.Smg1.Trigger local BarrelEnd = workspace.Smg1.BarrelEnd local Smg = script.Parent weld = Instance.new("Weld") weld.Part0 = NonMoving weld.C0 = NonMoving.CFrame:inverse() weld.Part1 = LoadingMech weld.C1 = LoadingMech.CFrame:inverse() weld.Parent = script.Parent weld1 = Instance.new("Weld") weld1.Part0 = Handle weld1.C0 = Handle.CFrame:inverse() weld1.Part1 = NonMoving weld1.C1 = NonMoving.CFrame:inverse() weld1.Parent = script.Parent weld2 = Instance.new("Weld") weld2.Part0 = Stock weld2.C0 = Stock.CFrame:inverse() weld2.Part1 = NonMoving weld2.C1 = NonMoving.CFrame:inverse() weld2.Parent = script.Parent weld3 = Instance.new("Weld") weld3.Part0 = Trigger weld3.C0 = Trigger.CFrame:inverse() weld3.Part1 = NonMoving weld3.C1 = NonMoving.CFrame:inverse() weld3.Parent = script.Parent weld4 = Instance.new("Weld") weld4.Part0 = Magazine weld4.C0 = Magazine.CFrame:inverse() weld4.Part1 = NonMoving weld4.C1 = NonMoving.CFrame:inverse() weld4.Parent = script.Parent weld5 = Instance.new("Weld") weld5.Part0 = BarrelEnd weld5.C0 = BarrelEnd.CFrame:inverse() weld5.Part1 = NonMoving weld5.C1 = NonMoving.CFrame:inverse() weld5.Parent = script.Parent local Players = GetService:Players --Smg.Parent.Changed:connect(function (hit) -- local Pname = game.Players:GetPlayerFromCharacter(hit.Parent) ---- if Pname ~= nil then -- print(Pname) -- Handle = workspace.Pname.Smg1.Handle -- LoadingMech = workspace.Pname.Smg1.LoadingMech -- Magazine = workspace.Pname.Smg1.Magazine -- NonMoving = workspace.Pname.Smg1.NonMoving -- Stock = workspace.Pname.Smg1.Stock -- Trigger = workspace.Pname.Smg1.Trigger -- BarrelEnd = workspace.Pname.Smg1.BarrelEnd -- --end ----end)
*This does NOT work, and I know. Someone who knows a lot about scripting would probably look at this and laugh. But please, keep criticism to constructive, I would really like that =)
*The top part does but when its equipped, it unwelds and I have to change ALL of the welds. ._.