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: Welding a sword to a NPC's arm?

Previous Thread :: Next Thread 
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
22 Jun 2013 12:30 PM
local swo = script.Parent

local x = Instance.new("Weld")
x.Parent = swo
x.Part0 = swo.Sword
x.Part1 = swo.RightArm

--Would this be right? Can't weld very good.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Jun 2013 12:40 PM
function weld(part0,part1,c1)
local weld = Instance.new("Weld",part0)
for n,o in pairs({C1=c1,Part0=part0,Part1=part1})do
weld[n] = o
end
return weld end

local w = weld(Workspace.A,Workspace.B,CFrame.new(0,0,-1))

Mess with this.

donut first, answer later
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
22 Jun 2013 12:41 PM
function weld(part0,part1,c1)
local weld = Instance.new("Weld",part0)
for n,o in pairs({C1=c1,Part0=part0,Part1=part1})do
weld[n] = o
end
return weld end
swo = script.Parent
local w = weld(swo.Sword,swo.RightArm,CFrame.new(0,0,-1))

Mess with this.

donut first, answer later
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
22 Jun 2013 01:08 PM
I dont' get it.
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
22 Jun 2013 01:22 PM
I often use this as a Weld script.

arm = .........
handle = ...........


local W = Instance.new("Weld")
W.Part0 = handle
W.Part1 = arm
local CJ = CFrame.new(handle.Position)
local C0 = handle.CFrame:inverse()*CJ
local C1 = arm.CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = handle



I also often use this one.
This script welds all objects with ClassName 'part' that are grouped with the script.


weldto = script.Parent.weldto

C = script.Parent:GetChildren()
for i = 1, #C do
if C[i].ClassName == 'Part' then
local W = Instance.new("Weld")
W.Part0 = C[i]
W.Part1 = weldto
local CJ = CFrame.new(C[i].Position)
local C0 = C[i].CFrame:inverse()*CJ
local C1 = weldto.CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = C[i]
C[i].Anchored = false
end
end
Report Abuse
darkero99 is not online. darkero99
Joined: 11 Mar 2011
Total Posts: 399
22 Jun 2013 02:14 PM
@^

We have the same, except I use different variables.
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