generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: C-Framed Weld Scripts

Previous Thread :: Next Thread 
ethansoh11 is not online. ethansoh11
Joined: 15 Aug 2010
Total Posts: 1201
07 Mar 2012 02:14 PM
I'm looking for a weld script that will hold C-framed bricks together for my gun. This one won't work:

c = script.Parent:getChildren()
for a = 1, #c do
if c[a].Name ~= "Handle" and c[a].className == "Part" then
value = Instance.new("CFrameValue")
value.Parent = script.Parent.Handle
value.Name = (c[a].Name.."CF")
value.Value = c[a].CFrame:inverse()*script.Parent.Handle.CFrame
end
end

function weld()
c = script.Parent:getChildren()
for a = 1, #c do
if c[a].className == "Part" and c[a].Name ~= "Handle" then
weld = Instance.new("Weld")
weld.Parent = script.Parent.Handle
weld.Part0 = weld.Parent
weld.Part1 = c[a]
weld.C1 = script.Parent.Handle[c[a].Name.."CF"].Value
end
end
end

script.Parent.Equipped:connect(weld)
weld()

c = script.Parent:getChildren()
for a = 1, #c do
if c[a].className == "Part" then
c[a].Anchored = false
end
end


Im using 4 total parts for my gun. A handle,hole,and two pats. Please respond
Report Abuse
WhoBloxedWho is not online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
07 Mar 2012 03:16 PM

function stick(x, y)
weld = Instance.new("Weld")
weld.Part0 = x
weld.Part1 = y
local HitPos = x.Position
local CJ = CFrame.new(HitPos)
local C0 = x.CFrame:inverse() *CJ
local C1 = y.CFrame:inverse() * CJ
weld.C0 = C0
weld.C1 = C1
weld.Parent = x
end

stick(MainPart,YourPartYouWantWelded)

make sure you make the x of the function the main part you want all of the other parts (the y) to be welded to
Report Abuse
ethansoh11 is not online. ethansoh11
Joined: 15 Aug 2010
Total Posts: 1201
07 Mar 2012 05:10 PM
Will this work for my gun?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image