User:TeamGalaxyMaster/TGM's quick Scripts!

Introduction
Hi, I am TGM I do scripting tutorials on my Youtube! This will have lots of walkthroughs on making certain scripts!

Contents
That is all for now!
 * Weld Script
 * Data Save Script (Coming soon)
 * Gun Script (coming soon)

Introduction
A weld sticks parts together, its like anchoring but you can move it around. Weld scripts might seem impossible to understand if you seen one in a free model similar to this:

local all,last = {}

function scan(p)

for _,v in pairs(p:GetChildren) do

if (v:IsA("BasePart")) then

if (last) then

undefined

w.Part0,w.Part1 = last,v

undefined

undefined

end

table.insert(all,v)

undefined

end

scan(v)

end

end

scan(script.Parent)

for _,v in pairs(all) do v.Anchored = false end

Well that is far too complicated, this one is easy to understand and a lot smaller

Benefits
You can use this for a weapon to stick all the parts together. Make an object a player can push around and much more!

Start
Put all your Parts into a model, tool or a folder (anything that holds groups of items). Make sure every part is not anchored. Insert a script into the handle (if it is a weapon) or a part.

Script
First lets make some variables...

undefined

undefined

Now lets get the parts

undefined

undefined

undefined

end

Now lets check if the parts are not anything else

undefined

undefined

undefined

if parts[i]:IsA("BasePart") then --If it is a part

end

end

Now lets make the weld

undefined

undefined

undefined

if parts[i]:IsA("BasePart") then --If it is a part

undefined

undefined

undefined

undefined

undefined

undefined

end

end

Finish
That is it! You might have noticed I have a union in my model if you have a mesh or union then insert this

undefined

if parts[i]:IsA("BasePart") then --If it is a part

undefined

undefined

undefined

undefined

undefined

undefined

elseif parts[i]:IsA("UnionOperation") then --If it is not a union the get the class name and copy it into the ""

undefined

undefined

undefined

undefined

undefined

undefined

end

end