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: Guns fall apart after equipping?

Previous Thread :: Next Thread 
HuntsmanSniper is not online. HuntsmanSniper
Joined: 19 May 2010
Total Posts: 96
25 Jun 2013 11:15 PM
Hi everyone. I'm working on a gun tool atm. I have my gun ready, I can put it into a tool perfectly fine, I have a weld script inside of the handle and I can actually pick up the gun perfectly fine, no issues. However, when I un-equip and then re-equip the gun, it all falls apart. Is there something I'm missing here? I don't quite see why it works fine, and then just breaks the second I re-equip it? Any help would be awesome, ty :3.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
25 Jun 2013 11:17 PM
You need the weld script to weld it everytime you equip it.

tool.Equipped:connect(function()
--weld stuff
end)
Report Abuse
babyyip is not online. babyyip
Joined: 17 Mar 2012
Total Posts: 4927
25 Jun 2013 11:18 PM
@Sam
Yet you don't give me the right script for a back flip script
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
25 Jun 2013 11:20 PM
@babyyip - That requires way more than this does. There is not built in function, that I know of, that will make a player do a backflip.
Report Abuse
HuntsmanSniper is not online. HuntsmanSniper
Joined: 19 May 2010
Total Posts: 96
25 Jun 2013 11:25 PM
It seems to weld, but the pieces fall apart before they weld, so they just end up floating. My full script is as follows:

--------------------------------------------------------

MainPart = script.Parent
t = script.Parent.Parent

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 = y
end

function Weldnow()
c = t:children()
for n = 1, #c do
if (c[n].className == "Part") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "Flag") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "Handle") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "Hat") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "Seat") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "SpawnLocation") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "TrussPart") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end

if (c[n].className == "VehicleSeat") then
if (c[n].Name ~= MainPart.Name) then
stick(c[n], MainPart)
wait()
c[n].Anchored = false
end
end
end
end

wait()

script.Parent.Anchored = false

Weldnow()
t.Equipped:connect(Weldnow)

---------------------------------------------------------------------------------

Report Abuse
HuntsmanSniper is not online. HuntsmanSniper
Joined: 19 May 2010
Total Posts: 96
25 Jun 2013 11:31 PM
Ah, I think I was just using a rubbish tool weld, and the series of welds/unwelds was all out of order. Thanks for your help :3.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
25 Jun 2013 11:39 PM
You got it to work? :)
Report Abuse
HuntsmanSniper is not online. HuntsmanSniper
Joined: 19 May 2010
Total Posts: 96
25 Jun 2013 11:43 PM
I did :3
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
25 Jun 2013 11:43 PM
Awesome . :)
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