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: My gun is too heavy

Previous Thread :: Next Thread 
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:34 AM
A friend made a gun and asked me to script it for him, but when i turned it into a tool its to heavy for the player. It causes anyone who's carrying it's feet to sink into the ground.

I've had someone suggest putting a body force equal the the guns mass*192 into the handle, and i tried that but it had the effect of a gravity coil when you jumped.

Are there any other ways of making the player not sink through the ground?
Report Abuse
cheetosrevenge is not online. cheetosrevenge
Joined: 15 Apr 2011
Total Posts: 12565
29 Jul 2014 11:37 AM
"friend"

chk chk boom
Report Abuse
connor954 is not online. connor954
Joined: 24 Jul 2008
Total Posts: 947
29 Jul 2014 11:39 AM
Are the parts as thin as they could be? I've never worked with mass, so would that have any effect?
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:40 AM
@connor

I'm not really sure. It was made as a big model and resized with a plugin to be tool-sized
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:46 AM
Is there a way to fix this or does the gun need to be remade?
Report Abuse
connor954 is not online. connor954
Joined: 24 Jul 2008
Total Posts: 947
29 Jul 2014 11:47 AM
Meshes are the easiest way to go. With player made guns, you have to weld every single part together.
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:48 AM
@connor

Thats what I did. I know there are other games on roblox with guns with large amounts of bricks, so why does mine sink through the floor?
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 Jul 2014 11:48 AM
I'll repost what I said here: http://www.roblox.com/Forum/ShowPost.aspx?PostID=141877366

Use a bodyforce to cancel the gravity out. I don't know for sure how the process goes, but the gravity coil has a piece of code that makes hats weightless.

But I think it goes like this

local modelstuff = modelhere:GetChildren()
local totalforce = 0
for i=1,#modelstuff do
if modelstuff[i].ClassName == "Part" then
local totalforce = totalforce + modelstuff[i]:GetMass()
end
end
--then you multiply it by some number that I forgot, and put it in the bodyforce in handle
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:50 AM
@teh

I did that. I got the mass, multiplied it by 192, and then inserted it into the handle in a body force.

It just makes me float up when i jump
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
29 Jul 2014 11:53 AM
wtf

haven't any of you learned from guns on free mods? Thats how I started making guns (but now I use models for my guns, not those ugly slopy toolz)

this script is supposed to weld a gun together when equipped. (the gun must be anchored)


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

function Get(A)
if A.className == "Part" then
Weld(script.Parent.Handle, A)
A.Anchored = false
else
local C = A:GetChildren()
for i=1, #C do
Get(C[i])
end
end
end

function Finale()
Get(script.Parent)
end

script.Parent.Equipped:connect(Finale)
script.Parent.Unequipped:connect(Finale)
Finale()
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
29 Jul 2014 11:55 AM
The BodyForce thing doesn't work, I had the same issue with morphs I made a while ago.

My solution was to resize everything to 0.2x0.2x0.2 and insert meshes/resize meshes. I have a script for it, here you go:

local function RemoveWeight(model)
local function recursive(obj)
for _, child in pairs(obj:GetChildren()) do
if child:IsA("BasePart") then
local cf = child.CFrame
local has_mesh = false
for _, mesh in pairs(child:GetChildren()) do
if mesh:IsA("BevelMesh") then
has_mesh = true
mesh.Scale = mesh.Scale * child.Size * 5
elseif mesh:IsA("SpecialMesh") then
has_mesh = true
if mesh.MeshType.Name ~= "FileMesh" then
mesh.Scale = mesh.Scale * child.Size * 5
end
end
end
if not has_mesh then Instance.new("BlockMesh", child).Scale = child.Size * 5 end
child.formFactor = "Custom"
child.Size = Vector3.new(0.2, 0.2, 0.2)
child.CFrame = cf
end
recursive(child)
end
end
recursive(model)
end

RemoveWeight(Workspace.Model) -- Change that to the gun
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:55 AM
@Accomplishable

did you even read my post?

I made the tool. Its all welded together. But when i equip it, the tool(which is welded together), causes my legs(the ones on my character) to fall through the ground.

Thank you for trying to help, but my post doesnt even mention welds in it
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
29 Jul 2014 11:55 AM
@op Use a smaller number then. (for example, divide 192 by 0.5, to give it half the gravitational pull.)
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
29 Jul 2014 11:55 AM
Accomplishable, that's not the problem.
Report Abuse
HillBilliards is not online. HillBilliards
Joined: 05 Jan 2009
Total Posts: 13906
29 Jul 2014 11:59 AM
@nice

thank you
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
29 Jul 2014 12:04 PM
With the CSG Modeler coming out, soon you won't have to worry about this at all...
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
29 Jul 2014 12:17 PM
Actually the CSG wouldn't really help at all, since it would be the same mass. You'd still need my workaround.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
29 Jul 2014 12:22 PM
nice actually is is less mass

you can have 10000 parts in 1 cube meter or
one part that is 1 meter by 1 meter
Report Abuse
connor954 is not online. connor954
Joined: 24 Jul 2008
Total Posts: 947
29 Jul 2014 12:23 PM
CSG will be a sight for sore eyes to the old custom mesh makers.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
29 Jul 2014 01:21 PM
I was actually referring to connor's post, where he said it's easier to use meshes, and since you have to weld every single part in the gun together. You were replying after that, so I referred to both of you
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
29 Jul 2014 01:22 PM
Actually, it would be less mass.

Mass ~= volume
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
29 Jul 2014 01:23 PM
And if your gun's making you fall through the ground, how about you use common sense and make it smaller (I'm sure you're not THAT stupid enough to where you can't even build it). Don't see why you're posting a thread because your gun is too big. Get a brain, flower head
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
29 Jul 2014 01:25 PM
@Accomp,

resizing a gun can be some unneeded work if he's just looking for a way to reduce its weight. Besides, resizing might ruin some aesthetic to the gun (maybe he was going for big).

I don't blame him at all for making this thread.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
29 Jul 2014 01:25 PM
And to anyone besides the OP,

tl;dr
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
29 Jul 2014 01:27 PM
>And to anyone besides the OP,

tl;dr


>Actually, it would be less mass.

Mass ~= volume

much lazy, such wow
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