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 » Scripters
Home Search
 

Re: Weld ontouch

Previous Thread :: Next Thread 
EPIKGAMERMAN is not online. EPIKGAMERMAN
Joined: 12 Dec 2012
Total Posts: 8781
03 Mar 2015 10:18 AM
If any part touches it, it would automatically weld itself to it. Is there any possible way to achieve this?
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
03 Mar 2015 10:20 AM
Yes, there is a possible way to achieve this.

⬡
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
03 Mar 2015 10:26 AM
@DeviousDeviation

Really helpful..



a = Instance.new("Part", workspace) -- for testing
deb = false

a.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players"):FindFirstChild(hit.Parent.Name) ~=nil and deb == false then
deb = true
local weld = Instance.new("Weld", hit)
weld.Part0 = hit.Parent:FindFirstChild("Humanoid")
weld.Part1 = a

end
end)

Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
03 Mar 2015 10:27 AM
whoops i make easy mistake..

a = Instance.new("Part", workspace) -- for testing
deb = false

a.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players"):FindFirstChild(hit.Parent.Name) ~=nil and deb == false then
deb = true
local weld = Instance.new("Weld", hit)
weld.Part0 = hit.Parent:FindFirstChild("Humanoid")
weld.Part1 = a
wait(1)
deb = false
end
end)
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
03 Mar 2015 10:29 AM
function Weld(b, a, parent)
local c = Instance.new("Weld")
c.Part0 = a
c.Part1 = b
c.C0 = a.CFrame:inverse() * CFrame.new(a.Position)
c.C1 = b.CFrame:inverse() * CFrame.new(a.Position)
c.Parent = (not parent and game.JointsService) or parent
return c
end

This function takes two parts as arguments and will attach them together in their current positions. You don't need to supply a parent argument, but you can if you like.
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
03 Mar 2015 10:29 AM
weld.Part0 = hit -- not humanoid sorry.
Report Abuse
EPIKGAMERMAN is not online. EPIKGAMERMAN
Joined: 12 Dec 2012
Total Posts: 8781
03 Mar 2015 10:54 AM
Thanks. Was really helpful.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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